Skip to content

Commit e2c691e

Browse files
committed
[509] Implement support for logical quotas
This commit introduces a new endpoint, /logical-quotas, which supports the following operations: - stat - set_quota - recalculate
1 parent 9f210ba commit e2c691e

10 files changed

Lines changed: 735 additions & 1 deletion

File tree

‎API.md‎

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,131 @@ If an HTTP status code of 200 is returned, the body of the response will contain
16111611

16121612
If there was an error, expect an HTTP status code in either the 4XX or 5XX range.
16131613

1614+
## Logical Quota Operations
1615+
1616+
### stat
1617+
1618+
Returns quota information for one or more collections.
1619+
1620+
> [!WARNING]
1621+
> This operation requires rodsadmin level privileges.
1622+
1623+
#### Request
1624+
1625+
HTTP Method: GET
1626+
1627+
```bash
1628+
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
1629+
-H 'Authorization: Bearer <token>' \
1630+
--data-urlencode 'op=stat' \
1631+
--data-urlencode 'lpath=<string>' \ # Absolute logical path to a collection. Optional.
1632+
-G
1633+
```
1634+
1635+
If `lpath` points to a valid collection, the HTTP API will return quota information for that collection and all its ancestors.
1636+
1637+
If a target collection is not provided via the `lpath` parameter, the HTTP API will return quota information for all collections in the zone.
1638+
1639+
#### Response
1640+
1641+
If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.
1642+
1643+
```js
1644+
{
1645+
"irods_response": {
1646+
"status_code": 0
1647+
"status_message": "string" // Optional
1648+
},
1649+
"quotas": [
1650+
{
1651+
"collection": "string",
1652+
"max_bytes": 0,
1653+
"max_objects": 0,
1654+
"over_bytes": 0,
1655+
"over_objects": 0
1656+
},
1657+
1658+
// Additional entries ...
1659+
]
1660+
}
1661+
```
1662+
1663+
If there was an error, expect an HTTP status code in either the 4XX or 5XX range.
1664+
1665+
### set_quota
1666+
1667+
Sets the quota for a collection.
1668+
1669+
> [!WARNING]
1670+
> This operation requires rodsadmin level privileges.
1671+
1672+
#### Request
1673+
1674+
HTTP Method: POST
1675+
1676+
```bash
1677+
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
1678+
-H 'Authorization: Bearer <token>' \
1679+
--data-urlencode 'op=set_quota' \
1680+
--data-urlencode 'lpath=<string>' \ # Absolute logical path to the collection which the quota applies.
1681+
--data-urlencode 'maximum-bytes=<integer>' \ # The number of bytes which will serves as the byte limit. Optional.
1682+
--data-urlencode 'maximum-objects=<integer>' # The number of objects which will serve as the limit. Optional.
1683+
```
1684+
1685+
`maximum-bytes` and/or `maximum-objects` MUST be specified for this operation to succeed.
1686+
1687+
To remove a quota, set `maximum-bytes` and `maximum-objects` to 0.
1688+
1689+
#### Response
1690+
1691+
If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.
1692+
1693+
```js
1694+
{
1695+
"irods_response": {
1696+
"status_code": 0
1697+
"status_message": "string" // Optional
1698+
}
1699+
}
1700+
```
1701+
1702+
If there was an error, expect an HTTP status code in either the 4XX or 5XX range.
1703+
1704+
### recalculate
1705+
1706+
Calculate or update quota information based on the state of the catalog.
1707+
1708+
> [!WARNING]
1709+
> This operation requires rodsadmin level privileges.
1710+
1711+
> [!IMPORTANT]
1712+
> iRODS does not automatically update quota information as data changes. This operation is provided to give administrators control over how frequently totals are calculated.
1713+
1714+
#### Request
1715+
1716+
HTTP Method: POST
1717+
1718+
```bash
1719+
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
1720+
-H 'Authorization: Bearer <token>' \
1721+
--data-urlencode 'op=recalculate'
1722+
```
1723+
1724+
#### Response
1725+
1726+
If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.
1727+
1728+
```js
1729+
{
1730+
"irods_response": {
1731+
"status_code": 0
1732+
"status_message": "string" // Optional
1733+
}
1734+
}
1735+
```
1736+
1737+
If there was an error, expect an HTTP status code in either the 4XX or 5XX range.
1738+
16141739
## Resource Operations
16151740

16161741
### create

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ target_link_objects(
162162
#irods_http_api_endpoint_config
163163
irods_http_api_endpoint_data_objects
164164
irods_http_api_endpoint_information
165+
irods_http_api_endpoint_logical_quotas
165166
irods_http_api_endpoint_physical_quotas
166167
irods_http_api_endpoint_query
167168
irods_http_api_endpoint_resources

‎core/src/main.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const irods::http::request_handler_map_type req_handlers{
101101
//{IRODS_HTTP_API_BASE_URL "/config", irods::http::handler::configuration},
102102
{IRODS_HTTP_API_BASE_URL "/data-objects", irods::http::handler::data_objects},
103103
{IRODS_HTTP_API_BASE_URL "/info", irods::http::handler::information},
104+
{IRODS_HTTP_API_BASE_URL "/logical-quotas", irods::http::handler::logical_quotas},
104105
{IRODS_HTTP_API_BASE_URL "/physical-quotas", irods::http::handler::physical_quotas},
105106
{IRODS_HTTP_API_BASE_URL "/query", irods::http::handler::query},
106107
{IRODS_HTTP_API_BASE_URL "/resources", irods::http::handler::resources},

‎endpoints/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_subdirectory(collections)
55
#add_subdirectory(config)
66
add_subdirectory(data_objects)
77
add_subdirectory(information)
8+
add_subdirectory(logical_quotas)
89
add_subdirectory(physical_quotas)
910
add_subdirectory(query)
1011
add_subdirectory(resources)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
add_library(
2+
irods_http_api_endpoint_logical_quotas
3+
OBJECT
4+
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
5+
)
6+
7+
target_compile_definitions(
8+
irods_http_api_endpoint_logical_quotas
9+
PRIVATE
10+
${IRODS_COMPILE_DEFINITIONS}
11+
${IRODS_COMPILE_DEFINITIONS_PRIVATE}
12+
)
13+
14+
target_link_libraries(
15+
irods_http_api_endpoint_logical_quotas
16+
PRIVATE
17+
irods_client
18+
CURL::libcurl
19+
nlohmann_json::nlohmann_json
20+
)
21+
22+
target_include_directories(
23+
irods_http_api_endpoint_logical_quotas
24+
PRIVATE
25+
"${IRODS_HTTP_PROJECT_SOURCE_DIR}/core/include"
26+
"${IRODS_HTTP_PROJECT_BINARY_DIR}/core/include"
27+
"${IRODS_HTTP_PROJECT_SOURCE_DIR}/endpoints/shared/include"
28+
"${IRODS_EXTERNALS_FULLPATH_BOOST}/include"
29+
)
30+
31+
set_target_properties(irods_http_api_endpoint_logical_quotas PROPERTIES EXCLUDE_FROM_ALL TRUE)

0 commit comments

Comments
 (0)