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
d653b80b
Commit
d653b80b
authored
Dec 22, 2022
by
Marcin Haba
Browse files
baculum: Add offset parameter to event and pool list endpoint
parent
2fa22dca
Changes
5
Hide whitespace changes
Inline
Side-by-side
gui/baculum/protected/API/Modules/EventManager.php
View file @
d653b80b
...
...
@@ -38,7 +38,7 @@ class EventManager extends APIModule {
* @param array $time_scope time range for events time
* @param int|null $limit_val limit results value
*/
public
function
getEvents
(
$criteria
=
[],
$time_scope
=
[],
$limit_val
=
null
)
{
public
function
getEvents
(
$criteria
=
[],
$time_scope
=
[],
$limit_val
=
0
,
$offset_val
=
0
)
{
$sort_col
=
'EventsId'
;
$db_params
=
$this
->
getModule
(
'api_config'
)
->
getConfig
(
'db'
);
if
(
$db_params
[
'type'
]
===
Database
::
PGSQL_TYPE
)
{
...
...
@@ -49,6 +49,10 @@ class EventManager extends APIModule {
if
(
is_int
(
$limit_val
)
&&
$limit_val
>
0
)
{
$limit
=
' LIMIT '
.
$limit_val
;
}
$offset
=
''
;
if
(
is_int
(
$offset_val
)
&&
$offset_val
>
0
)
{
$offset
=
' OFFSET '
.
$offset_val
;
}
$where
=
Database
::
getWhere
(
$criteria
,
true
);
...
...
@@ -64,7 +68,7 @@ class EventManager extends APIModule {
$where
[
'where'
]
=
' WHERE '
.
$where
[
'where'
];
}
$sql
=
'SELECT Events.* FROM Events '
.
$where
[
'where'
]
.
$order
.
$limit
;
$sql
=
'SELECT Events.* FROM Events '
.
$where
[
'where'
]
.
$order
.
$limit
.
$offset
;
return
EventRecord
::
finder
()
->
findAllBySql
(
$sql
,
$where
[
'params'
]);
}
...
...
gui/baculum/protected/API/Modules/PoolManager.php
View file @
d653b80b
...
...
@@ -32,7 +32,7 @@ use Prado\Data\ActiveRecord\TActiveRecordCriteria;
* @package Baculum API
*/
class
PoolManager
extends
APIModule
{
public
function
getPools
(
$limit
)
{
public
function
getPools
(
$limit
_val
=
0
,
$offset_val
=
0
)
{
$criteria
=
new
TActiveRecordCriteria
;
$order
=
'Name'
;
$db_params
=
$this
->
getModule
(
'api_config'
)
->
getConfig
(
'db'
);
...
...
@@ -40,8 +40,11 @@ class PoolManager extends APIModule {
$order
=
strtolower
(
$order
);
}
$criteria
->
OrdersBy
[
$order
]
=
'asc'
;
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
PoolRecord
::
finder
()
->
findAll
(
$criteria
);
}
...
...
gui/baculum/protected/API/Pages/API/Events.php
View file @
d653b80b
...
...
@@ -34,6 +34,7 @@ class Events 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
;
$eventscode
=
$this
->
Request
->
contains
(
'eventscode'
)
&&
$misc
->
isValidName
(
$this
->
Request
[
'eventscode'
])
?
$this
->
Request
[
'eventscode'
]
:
null
;
$eventstype
=
$this
->
Request
->
contains
(
'eventstype'
)
&&
$misc
->
isValidName
(
$this
->
Request
[
'eventstype'
])
?
$this
->
Request
[
'eventstype'
]
:
null
;
$eventstimestart
=
$this
->
Request
->
contains
(
'eventstimestart'
)
&&
$misc
->
isValidBDate
(
$this
->
Request
[
'eventstimestart'
])
?
$this
->
Request
[
'eventstimestart'
]
:
null
;
...
...
@@ -81,7 +82,7 @@ class Events extends BaculumAPIServer {
$time_scope
[
'eventstimeend'
]
=
$eventstimeend
;
}
$events
=
$this
->
getModule
(
'event'
)
->
getEvents
(
$params
,
$time_scope
,
$limit
);
$events
=
$this
->
getModule
(
'event'
)
->
getEvents
(
$params
,
$time_scope
,
$limit
,
$offset
);
$this
->
output
=
$events
;
$this
->
error
=
EventError
::
ERROR_NO_ERRORS
;
}
...
...
gui/baculum/protected/API/Pages/API/Pools.php
View file @
d653b80b
...
...
@@ -32,8 +32,10 @@ use Baculum\Common\Modules\Errors\PoolError;
*/
class
Pools
extends
BaculumAPIServer
{
public
function
get
()
{
$misc
=
$this
->
getModule
(
'misc'
);
$limit
=
$this
->
Request
->
contains
(
'limit'
)
?
intval
(
$this
->
Request
[
'limit'
])
:
0
;
$pools
=
$this
->
getModule
(
'pool'
)
->
getPools
(
$limit
);
$offset
=
$this
->
Request
->
contains
(
'offset'
)
&&
$misc
->
isValidInteger
(
$this
->
Request
[
'offset'
])
?
(
int
)
$this
->
Request
[
'offset'
]
:
0
;
$pools
=
$this
->
getModule
(
'pool'
)
->
getPools
(
$limit
,
$offset
);
$result
=
$this
->
getModule
(
'bconsole'
)
->
bconsoleCommand
(
$this
->
director
,
[
'.pool'
],
...
...
gui/baculum/protected/API/openapi_baculum.json
View file @
d653b80b
...
...
@@ -2763,9 +2763,14 @@
}
}
},
"parameters"
:
[{
"$ref"
:
"#/components/parameters/Limit"
}]
"parameters"
:
[
{
"$ref"
:
"#/components/parameters/Limit"
},
{
"$ref"
:
"#/components/parameters/Offset"
}
]
}
},
"/api/v2/pools/{poolid}"
:
{
...
...
@@ -7242,6 +7247,9 @@
{
"$ref"
:
"#/components/parameters/Limit"
},
{
"$ref"
:
"#/components/parameters/Offset"
},
{
"name"
:
"eventscode"
,
"in"
:
"query"
,
...
...
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