Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,131 @@ If an HTTP status code of 200 is returned, the body of the response will contain

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

## Logical Quota Operations

### stat

Returns quota information for one or more collections.

> [!WARNING]
> This operation requires rodsadmin level privileges.

#### Request

HTTP Method: GET

```bash
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
-H 'Authorization: Bearer <token>' \
--data-urlencode 'op=stat' \
--data-urlencode 'lpath=<string>' \ # Absolute logical path to a collection. Optional.
-G
```

If `lpath` points to a valid collection, the HTTP API will return quota information for that collection and all its ancestors.

If a target collection is not provided via the `lpath` parameter, the HTTP API will return quota information for all collections in the zone.

#### Response

If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.

```js
{
"irods_response": {
"status_code": 0
"status_message": "string" // Optional
},
"quotas": [
{
"collection": "string",
"max_bytes": 0,
"max_objects": 0,
"over_bytes": 0,
"over_objects": 0
},

// Additional entries ...
]
}
```

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

### set_quota

Sets the quota for a collection.

> [!WARNING]
> This operation requires rodsadmin level privileges.

#### Request

HTTP Method: POST

```bash
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
-H 'Authorization: Bearer <token>' \
--data-urlencode 'op=set_quota' \
--data-urlencode 'lpath=<string>' \ # Absolute logical path to the collection which the quota applies.
--data-urlencode 'maximum-bytes=<integer>' \ # The number of bytes which will serves as the byte limit. Optional.
--data-urlencode 'maximum-objects=<integer>' # The number of objects which will serve as the limit. Optional.
Comment thread
korydraughn marked this conversation as resolved.
Outdated
```

`maximum-bytes` and/or `maximum-objects` MUST be specified for this operation to succeed.
Comment thread
korydraughn marked this conversation as resolved.
Outdated

To remove a quota, set `maximum-bytes` and `maximum-objects` to 0.
Comment thread
korydraughn marked this conversation as resolved.
Outdated

#### Response

If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.

```js
{
"irods_response": {
"status_code": 0
"status_message": "string" // Optional
}
}
```

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

### recalculate

Calculate or update quota information based on the state of the catalog.

> [!WARNING]
> This operation requires rodsadmin level privileges.

> [!IMPORTANT]
> iRODS does not automatically update quota information as data changes. This operation is provided to give administrators control over how frequently totals are calculated.

#### Request

HTTP Method: POST

```bash
curl http://localhost:<port>/irods-http-api/<version>/logical-quotas \
-H 'Authorization: Bearer <token>' \
--data-urlencode 'op=recalculate'
```

#### Response

If an HTTP status code of 200 is returned, the body of the response will contain JSON. Its structure is shown below.

```js
{
"irods_response": {
"status_code": 0
"status_message": "string" // Optional
}
}
```

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

## Resource Operations

### create
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ target_link_objects(
#irods_http_api_endpoint_config
irods_http_api_endpoint_data_objects
irods_http_api_endpoint_information
irods_http_api_endpoint_logical_quotas
irods_http_api_endpoint_physical_quotas
irods_http_api_endpoint_query
irods_http_api_endpoint_resources
Expand Down
1 change: 1 addition & 0 deletions core/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const irods::http::request_handler_map_type req_handlers{
//{IRODS_HTTP_API_BASE_URL "/config", irods::http::handler::configuration},
{IRODS_HTTP_API_BASE_URL "/data-objects", irods::http::handler::data_objects},
{IRODS_HTTP_API_BASE_URL "/info", irods::http::handler::information},
{IRODS_HTTP_API_BASE_URL "/logical-quotas", irods::http::handler::logical_quotas},
{IRODS_HTTP_API_BASE_URL "/physical-quotas", irods::http::handler::physical_quotas},
{IRODS_HTTP_API_BASE_URL "/query", irods::http::handler::query},
{IRODS_HTTP_API_BASE_URL "/resources", irods::http::handler::resources},
Expand Down
1 change: 1 addition & 0 deletions endpoints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_subdirectory(collections)
#add_subdirectory(config)
add_subdirectory(data_objects)
add_subdirectory(information)
add_subdirectory(logical_quotas)
add_subdirectory(physical_quotas)
add_subdirectory(query)
add_subdirectory(resources)
Expand Down
31 changes: 31 additions & 0 deletions endpoints/logical_quotas/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
add_library(
irods_http_api_endpoint_logical_quotas
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)

target_compile_definitions(
irods_http_api_endpoint_logical_quotas
PRIVATE
${IRODS_COMPILE_DEFINITIONS}
${IRODS_COMPILE_DEFINITIONS_PRIVATE}
)

target_link_libraries(
irods_http_api_endpoint_logical_quotas
PRIVATE
irods_client
CURL::libcurl
nlohmann_json::nlohmann_json
)

target_include_directories(
irods_http_api_endpoint_logical_quotas
PRIVATE
"${IRODS_HTTP_PROJECT_SOURCE_DIR}/core/include"
"${IRODS_HTTP_PROJECT_BINARY_DIR}/core/include"
"${IRODS_HTTP_PROJECT_SOURCE_DIR}/endpoints/shared/include"
"${IRODS_EXTERNALS_FULLPATH_BOOST}/include"
)

set_target_properties(irods_http_api_endpoint_logical_quotas PROPERTIES EXCLUDE_FROM_ALL TRUE)
Loading
Loading