Method: Aspera::Api::AoC#context=
- Defined in:
- lib/aspera/api/aoc.rb
#context=(application) ⇒ Hash
Set the application context
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/aspera/api/aoc.rb', line 257 def context=(application) Aspera.assert_values(application, %i[files packages]) ws_id = if !public_link.nil? Log.log.debug('Using workspace of public link') public_link['data']['workspace_id'] elsif !private_link.nil? Log.log.debug('Using workspace of private link') private_link[:workspace_id] elsif @workspace_name.eql?(DEFAULT_WORKSPACE) if !current_user_info['default_workspace_id'].nil? Log.log.debug('Using default workspace'.green) current_user_info['default_workspace_id'] end elsif @workspace_name.nil? nil else lookup_by_name('workspaces', @workspace_name)['id'] end ws_info = if ws_id.nil? nil else read("workspaces/#{ws_id}") end @workspace_info = if ws_info.nil? { id: nil, name: 'Shared folders' } else { id: ws_info['id'], name: ws_info['name'] } end Log.log.debug{Log.dump(:context, @workspace_info)} return nil unless application.eql?(:files) @home_info = if !public_link.nil? assert_public_link_types(['view_shared_file']) { node_id: public_link['data']['node_id'], file_id: public_link['data']['file_id'] } elsif !private_link.nil? { node_id: private_link[:node_id], file_id: private_link[:file_id] } elsif ws_info { node_id: ws_info['home_node_id'], file_id: ws_info['home_file_id'] } else # not part of any workspace, but has some folder shared user_info = current_user_info(exception: true) rescue {'read_only_home_node_id' => nil, 'read_only_home_file_id' => nil} { node_id: user_info['read_only_home_node_id'], file_id: user_info['read_only_home_file_id'] } end raise "Cannot get user's home node id, check your default workspace or specify one" if @home_info[:node_id].to_s.empty? Log.log.debug{Log.dump(:context, @home_info)} end |