Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
126 changes: 126 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,132 @@ If an HTTP status code of 200 is returned, the body of the response will contain
}
```

## Quota Operations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all under an "admin only" heading? if not, should we mention that this is all admin only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all quota operations admin only? iquota?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the operations in this PR except stat require admin privileges.

I haven't looked at what iquota does too closely. Will take a peek.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all under an "admin only" heading? if not, should we mention that this is all admin only?

Forgot about the admin-ness of these ops. Will add a note to each operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, not sure about groupadmins...


### stat

Returns global and resource quota information for one or more groups.

#### Request

HTTP Method: GET

```bash
curl http://localhost:<port>/irods-http-api/<version>/quotas \
-H 'Authorization: Bearer <token>' \
--data-urlencode 'op=stat' \
--data-urlencode 'group=<string>' \ # The group on which to report. Optional.
-G
```

If a target group is not provided via the `group` parameter, the HTTP API will return quota information for all groups across 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
},
"global_quotas": [
{
"group": "string",
"limit": 0,
"over": 0,
"modified_at": "string"
},

// Additional entries ...
],
"resource_quotas": [
{
"group": "string",
"resource": "string",
"limit": 0,
"over": 0,
"modified_at": "string"
},

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

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

### set_group_quota

Sets the quota for a group, optionally scoped to a single resource.

This operation requires rodsadmin level privileges.

#### Request

HTTP Method: POST

```bash
curl http://localhost:<port>/irods-http-api/<version>/quotas \
-H 'Authorization: Bearer <token>' \
--data-urlencode 'op=set_group_quota' \
--data-urlencode 'group=<string>' \ # The group to which the new quota applies.
--data-urlencode 'resource=<string>' \ # The resource to which the new quota applies. Optional.
--data-urlencode 'quota=<integer>' # The number of bytes which will serve as the quota limit.
```

If a target resource is not provided via the `resource` parameter, the quota will be treated as a global quota. Writing data to one or more resources will count towards the group quota.

#### 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.

> [!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.

This operation requires rodsadmin level privileges.

#### Request

HTTP Method: POST

```bash
curl http://localhost:<port>/irods-http-api/<version>/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 @@ -163,6 +163,7 @@ target_link_objects(
irods_http_api_endpoint_data_objects
irods_http_api_endpoint_information
irods_http_api_endpoint_query
irods_http_api_endpoint_quotas
irods_http_api_endpoint_resources
irods_http_api_endpoint_rules
irods_http_api_endpoint_tickets
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 "/data-objects", irods::http::handler::data_objects},
{IRODS_HTTP_API_BASE_URL "/info", irods::http::handler::information},
{IRODS_HTTP_API_BASE_URL "/query", irods::http::handler::query},
{IRODS_HTTP_API_BASE_URL "/quotas", irods::http::handler::quotas},
{IRODS_HTTP_API_BASE_URL "/resources", irods::http::handler::resources},
{IRODS_HTTP_API_BASE_URL "/rules", irods::http::handler::rules},
{IRODS_HTTP_API_BASE_URL "/tickets", irods::http::handler::tickets},
Expand Down
1 change: 1 addition & 0 deletions endpoints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_subdirectory(collections)
add_subdirectory(data_objects)
add_subdirectory(information)
add_subdirectory(query)
add_subdirectory(quotas)
add_subdirectory(resources)
add_subdirectory(rules)
add_subdirectory(tickets)
Expand Down
31 changes: 31 additions & 0 deletions endpoints/quotas/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
add_library(
irods_http_api_endpoint_quotas
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)

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

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

target_include_directories(
irods_http_api_endpoint_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_quotas PROPERTIES EXCLUDE_FROM_ALL TRUE)
Loading
Loading