Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F888034
clients_controller.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Aug 10, 8:48 AM
Size
1 KB
Mime Type
text/x-ruby
Expires
Tue, Aug 12, 8:48 AM (11 h, 31 m)
Engine
blob
Format
Raw Data
Handle
233206
Attached To
rARCHIVING archiving
clients_controller.rb
View Options
class
Api
::
V1
::
ClientsController
<
Api
::
BaseController
before_action
:require_api_login
before_action
:fetch_host
,
only
:
[
:show
,
:backup
,
:restore
]
before_action
:require_non_blocked_client
,
only
:
[
:backup
,
:restore
]
# GET /api/clients
def
index
hosts
=
current_api_user
.
hosts
.
in_bacula
api_render
(
hosts
)
end
# GET /api/clients/1
def
show
api_render
(
@host
)
end
# POST /api/clients/1/backup
def
backup
job
=
@host
.
job_templates
.
enabled
.
backup
.
find
(
params
[
:job_id
]
)
if
job
.
backup_now
message
=
'Job is scheduled for backup'
else
message
=
'Job can not be scheduled'
end
render
json
:
{
message
:
message
},
status
:
:ok
end
# POST /api/clients/1/restore
def
restore
fileset
=
@host
.
client
.
file_sets
.
find
(
params
[
:fileset_id
]
)
location
=
params
[
:location
].
blank?
?
'/tmp/bacula_restore'
:
params
[
:location
]
if
@host
.
restore
(
fileset
.
id
,
location
)
message
=
'Restore is scheduled'
else
message
=
'Restore not scheduled'
end
render
json
:
{
message
:
message
},
status
:
:ok
end
private
def
fetch_host
@host
=
current_api_user
.
hosts
.
in_bacula
.
find
(
params
[
:id
]
)
end
def
require_non_blocked_client
if
@host
.
blocked?
message
=
'Client is disabled by admins'
render
json
:
{
message
:
message
},
status
:
:ok
end
end
end
Event Timeline
Log In to Comment