Class: Files::Lock
- Inherits:
-
Object
- Object
- Files::Lock
- Defined in:
- lib/files.com/models/lock.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(path, params = {}, options = {}) ⇒ Object
Parameters: path (required) - string - Path allow_access_by_any_user - boolean - Can lock be modified by users other than its creator? exclusive - boolean - Is lock exclusive? recursive - boolean - Does lock apply to subfolders? timeout - int64 - Lock timeout in seconds.
-
.delete(path, params = {}, options = {}) ⇒ Object
Parameters: token (required) - string - Lock token.
- .destroy(path, params = {}, options = {}) ⇒ Object
-
.list_for(path, params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
Instance Method Summary collapse
-
#allow_access_by_any_user ⇒ Object
boolean - Can lock be modified by users other than its creator?.
- #allow_access_by_any_user=(value) ⇒ Object
-
#delete(params = {}) ⇒ Object
Parameters: token (required) - string - Lock token.
-
#depth ⇒ Object
string.
- #depth=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#exclusive ⇒ Object
boolean - Is lock exclusive?.
- #exclusive=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Lock
constructor
A new instance of Lock.
-
#owner ⇒ Object
string - Owner of the lock.
- #owner=(value) ⇒ Object
-
#path ⇒ Object
string - Path.
- #path=(value) ⇒ Object
-
#recursive ⇒ Object
boolean - Does lock apply to subfolders?.
- #recursive=(value) ⇒ Object
- #save ⇒ Object
-
#scope ⇒ Object
string.
- #scope=(value) ⇒ Object
-
#timeout ⇒ Object
int64 - Lock timeout in seconds.
- #timeout=(value) ⇒ Object
-
#token ⇒ Object
string - Lock token.
- #token=(value) ⇒ Object
-
#type ⇒ Object
string.
- #type=(value) ⇒ Object
-
#user_id ⇒ Object
int64 - Lock creator user ID.
- #user_id=(value) ⇒ Object
-
#username ⇒ Object
string - Lock creator username.
- #username=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Lock
Returns a new instance of Lock.
7 8 9 10 |
# File 'lib/files.com/models/lock.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/lock.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/lock.rb', line 5 def @options end |
Class Method Details
.create(path, params = {}, options = {}) ⇒ Object
Parameters:
path (required) - string - Path
allow_access_by_any_user - boolean - Can lock be modified by users other than its creator?
exclusive - boolean - Is lock exclusive?
recursive - boolean - Does lock apply to subfolders?
timeout - int64 - Lock timeout in seconds
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/files.com/models/lock.rb', line 169 def self.create(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: timeout must be an Integer") if params[:timeout] and !params[:timeout].is_a?(Integer) raise MissingParameterError.new("Parameter missing: path") unless params[:path] response, = Api.send_request("/locks/#{params[:path]}", :post, params, ) Lock.new(response.data, ) end |
.delete(path, params = {}, options = {}) ⇒ Object
Parameters:
token (required) - string - Lock token
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/files.com/models/lock.rb', line 182 def self.delete(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: token must be an String") if params[:token] and !params[:token].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: token") unless params[:token] Api.send_request("/locks/#{params[:path]}", :delete, params, ) nil end |
.destroy(path, params = {}, options = {}) ⇒ Object
194 195 196 197 |
# File 'lib/files.com/models/lock.rb', line 194 def self.destroy(path, params = {}, = {}) delete(path, params, ) nil end |
.list_for(path, 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).
path (required) - string - Path to operate on.
include_children - boolean - Include locks from children objects?
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/files.com/models/lock.rb', line 150 def self.list_for(path, params = {}, = {}) params ||= {} params[:path] = path 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: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] List.new(Lock, params) do Api.send_request("/locks/#{params[:path]}", :get, params, ) end end |
Instance Method Details
#allow_access_by_any_user ⇒ Object
boolean - Can lock be modified by users other than its creator?
94 95 96 |
# File 'lib/files.com/models/lock.rb', line 94 def allow_access_by_any_user @attributes[:allow_access_by_any_user] end |
#allow_access_by_any_user=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/lock.rb', line 98 def allow_access_by_any_user=(value) @attributes[:allow_access_by_any_user] = value end |
#delete(params = {}) ⇒ Object
Parameters:
token (required) - string - Lock token
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/files.com/models/lock.rb', line 122 def delete(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: token must be an String") if params[:token] and !params[:token].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: token") unless params[:token] Api.send_request("/locks/#{@attributes[:path]}", :delete, params, @options) end |
#depth ⇒ Object
string
31 32 33 |
# File 'lib/files.com/models/lock.rb', line 31 def depth @attributes[:depth] end |
#depth=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/lock.rb', line 35 def depth=(value) @attributes[:depth] = value end |
#destroy(params = {}) ⇒ Object
134 135 136 137 |
# File 'lib/files.com/models/lock.rb', line 134 def destroy(params = {}) delete(params) nil end |
#exclusive ⇒ Object
boolean - Is lock exclusive?
67 68 69 |
# File 'lib/files.com/models/lock.rb', line 67 def exclusive @attributes[:exclusive] end |
#exclusive=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/lock.rb', line 71 def exclusive=(value) @attributes[:exclusive] = value end |
#owner ⇒ Object
string - Owner of the lock. This can be any arbitrary string.
49 50 51 |
# File 'lib/files.com/models/lock.rb', line 49 def owner @attributes[:owner] end |
#owner=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/lock.rb', line 53 def owner=(value) @attributes[:owner] = value end |
#path ⇒ Object
string - Path. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
13 14 15 |
# File 'lib/files.com/models/lock.rb', line 13 def path @attributes[:path] end |
#path=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/lock.rb', line 17 def path=(value) @attributes[:path] = value end |
#recursive ⇒ Object
boolean - Does lock apply to subfolders?
40 41 42 |
# File 'lib/files.com/models/lock.rb', line 40 def recursive @attributes[:recursive] end |
#recursive=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/lock.rb', line 44 def recursive=(value) @attributes[:recursive] = value end |
#save ⇒ Object
139 140 141 142 143 |
# File 'lib/files.com/models/lock.rb', line 139 def save new_obj = Lock.create(path, @attributes, @options) @attributes = new_obj.attributes true end |
#scope ⇒ Object
string
58 59 60 |
# File 'lib/files.com/models/lock.rb', line 58 def scope @attributes[:scope] end |
#scope=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/lock.rb', line 62 def scope=(value) @attributes[:scope] = value end |
#timeout ⇒ Object
int64 - Lock timeout in seconds
22 23 24 |
# File 'lib/files.com/models/lock.rb', line 22 def timeout @attributes[:timeout] end |
#timeout=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/lock.rb', line 26 def timeout=(value) @attributes[:timeout] = value end |
#token ⇒ Object
string - Lock token. Use to release lock.
76 77 78 |
# File 'lib/files.com/models/lock.rb', line 76 def token @attributes[:token] end |
#token=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/lock.rb', line 80 def token=(value) @attributes[:token] = value end |
#type ⇒ Object
string
85 86 87 |
# File 'lib/files.com/models/lock.rb', line 85 def type @attributes[:type] end |
#type=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/lock.rb', line 89 def type=(value) @attributes[:type] = value end |
#user_id ⇒ Object
int64 - Lock creator user ID
103 104 105 |
# File 'lib/files.com/models/lock.rb', line 103 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
107 108 109 |
# File 'lib/files.com/models/lock.rb', line 107 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Lock creator username
112 113 114 |
# File 'lib/files.com/models/lock.rb', line 112 def username @attributes[:username] end |
#username=(value) ⇒ Object
116 117 118 |
# File 'lib/files.com/models/lock.rb', line 116 def username=(value) @attributes[:username] = value end |