Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bacula Community Edition
Bacula Community
Commits
2fa22dca
Commit
2fa22dca
authored
Dec 22, 2022
by
Marcin Haba
Browse files
baculum: Add offset parameter to storage and client list endpoint
parent
1372ab96
Changes
5
Hide whitespace changes
Inline
Side-by-side
gui/baculum/protected/API/Modules/ClientManager.php
View file @
2fa22dca
...
...
@@ -33,10 +33,13 @@ use Prado\Data\ActiveRecord\TActiveRecordCriteria;
*/
class
ClientManager
extends
APIModule
{
public
function
getClients
(
$limit
)
{
public
function
getClients
(
$limit
_val
=
0
,
$offset_val
=
0
)
{
$criteria
=
new
TActiveRecordCriteria
;
if
(
is_numeric
(
$limit
)
&&
$limit
>
0
)
{
$criteria
->
Limit
=
$limit
;
if
(
is_numeric
(
$limit_val
)
&&
$limit_val
>
0
)
{
$criteria
->
Limit
=
$limit_val
;
}
if
(
is_int
(
$offset_val
)
&&
$offset_val
>
0
)
{
$criteria
->
Offset
=
$offset_val
;
}
return
ClientRecord
::
finder
()
->
findAll
(
$criteria
);
}
...
...
gui/baculum/protected/API/Modules/StorageManager.php
View file @
2fa22dca
...
...
@@ -33,10 +33,13 @@ use Prado\Data\ActiveRecord\TActiveRecordCriteria;
*/
class
StorageManager
extends
APIModule
{
public
function
getStorages
(
$limit
)
{
public
function
getStorages
(
$limit
_val
=
0
,
$offset_val
=
0
)
{
$criteria
=
new
TActiveRecordCriteria
;
if
(
is_int
(
$limit
)
&&
$limit
>
0
)
{
$criteria
->
Limit
=
$limit
;
if
(
is_int
(
$limit_val
)
&&
$limit_val
>
0
)
{
$criteria
->
Limit
=
$limit_val
;
}
if
(
is_int
(
$offset_val
)
&&
$offset_val
>
0
)
{
$criteria
->
Offset
=
$offset_val
;
}
return
StorageRecord
::
finder
()
->
findAll
(
$criteria
);
}
...
...
gui/baculum/protected/API/Pages/API/Clients.php
View file @
2fa22dca
...
...
@@ -33,10 +33,12 @@ use Baculum\Common\Modules\Errors\ClientError;
class
Clients
extends
BaculumAPIServer
{
public
function
get
()
{
$misc
=
$this
->
getModule
(
'misc'
);
$limit
=
$this
->
Request
->
contains
(
'limit'
)
?
intval
(
$this
->
Request
[
'limit'
])
:
0
;
$offset
=
$this
->
Request
->
contains
(
'offset'
)
&&
$misc
->
isValidInteger
(
$this
->
Request
[
'offset'
])
?
(
int
)
$this
->
Request
[
'offset'
]
:
0
;
$result
=
$this
->
getModule
(
'bconsole'
)
->
bconsoleCommand
(
$this
->
director
,
array
(
'.client'
));
if
(
$result
->
exitcode
===
0
)
{
$clients
=
$this
->
getModule
(
'client'
)
->
getClients
(
$limit
);
$clients
=
$this
->
getModule
(
'client'
)
->
getClients
(
$limit
,
$offset
);
array_shift
(
$result
->
output
);
$clients_output
=
array
();
foreach
(
$clients
as
$client
)
{
...
...
gui/baculum/protected/API/Pages/API/Storages.php
View file @
2fa22dca
...
...
@@ -33,8 +33,10 @@ use Baculum\Common\Modules\Errors\StorageError;
class
Storages
extends
BaculumAPIServer
{
public
function
get
()
{
$misc
=
$this
->
getModule
(
'misc'
);
$limit
=
$this
->
Request
->
contains
(
'limit'
)
?
intval
(
$this
->
Request
[
'limit'
])
:
0
;
$storages
=
$this
->
getModule
(
'storage'
)
->
getStorages
(
$limit
);
$offset
=
$this
->
Request
->
contains
(
'offset'
)
&&
$misc
->
isValidInteger
(
$this
->
Request
[
'offset'
])
?
(
int
)
$this
->
Request
[
'offset'
]
:
0
;
$storages
=
$this
->
getModule
(
'storage'
)
->
getStorages
(
$limit
,
$offset
);
$result
=
$this
->
getModule
(
'bconsole'
)
->
bconsoleCommand
(
$this
->
director
,
array
(
'.storage'
)
...
...
gui/baculum/protected/API/openapi_baculum.json
View file @
2fa22dca
...
...
@@ -452,9 +452,14 @@
}
}
},
"parameters"
:
[{
"$ref"
:
"#/components/parameters/Limit"
}]
"parameters"
:
[
{
"$ref"
:
"#/components/parameters/Limit"
},
{
"$ref"
:
"#/components/parameters/Offset"
}
]
}
},
"/api/v2/clients/{clientid}"
:
{
...
...
@@ -2414,9 +2419,14 @@
}
}
},
"parameters"
:
[{
"$ref"
:
"#/components/parameters/Limit"
}]
"parameters"
:
[
{
"$ref"
:
"#/components/parameters/Limit"
},
{
"$ref"
:
"#/components/parameters/Offset"
}
]
}
},
"/api/v2/storages/{storageid}"
:
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment