You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "winterhazel (via GitHub)" <gi...@apache.org> on 2026/05/25 18:27:58 UTC

[PR] Introduce Quota resource statement API [cloudstack]

winterhazel opened a new pull request, #13236:
URL: https://github.com/apache/cloudstack/pull/13236

   ### Description
   
   This PR introduces the `quotaResourceStatement` API to the Quota plugin. This API allows viewing the Quota consumption associated with a specific resource. It will be used by the Quota UI rework in a separate PR.
   
   In addition, some adjustments were made in the `quotaStatement` API in order to allow including the consumption of subdomains in the resulting statement.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [X] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [X] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [X] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   ### How Has This Been Tested?
   
   I tested the API by fuzzing its parameters for root admin, domain admin, and user accounts. In the tests, I validated that the API returned the expected response while performing correct permission checking.
   
   ---
   
   ### Environment configuration
   
   My environment had two domains: `ROOT` and `d1`.
   
   ```sql
   MariaDB [cloud]> select uuid,name,path,parent from domain;
   +--------------------------------------+------+------+--------+
   | uuid                                 | name | path | parent |
   +--------------------------------------+------+------+--------+
   | de3f3dfb-f84b-11f0-8ace-32e0826870ba | ROOT | /    |   NULL |
   | dc5064ad-d4a8-4bb3-ae18-a52e4810ac3d | d1   | /d1/ |      1 |
   +--------------------------------------+------+------+--------+
   ```
   
   Each domain had a domain admin (`dr` for `ROOT` and `d1` for `d1`) and a user account (`ur` for `ROOT` and `u1` for `d1`). `ROOT` also had a project and the root admin.
   
   ```sql
   MariaDB [cloud]> select uuid,account_name,domain_id,role_id from account;
   +--------------------------------------+--------------------------+-----------+---------+
   | uuid                                 | account_name             | domain_id | role_id |
   +--------------------------------------+--------------------------+-----------+---------+
   | f684aae8-f84b-11f0-8ace-32e0826870ba | system                   |         1 |       1 |
   | f684da1a-f84b-11f0-8ace-32e0826870ba | admin                    |         1 |       1 |
   | 17dfdcce-fd02-46d0-85ae-7de91fda634c | baremetal-system-account |         1 |       4 |
   | aaba75a0-a575-41be-80e1-dbea14c10e51 | dr                       |         1 |       3 |
   | feaffae2-7ba4-45dc-b46f-20ae86192685 | d1                       |         2 |       3 |
   | 2f49212d-d6d5-437b-800d-a7bb4a8def4b | u1                       |         2 |       4 |
   | b029e8b8-e539-4d1a-906d-3d4f2fb36b82 | ur                       |         1 |       4 |
   | b14100c6-d9f6-450e-87a2-0833bb45e5f8 | PrjAcct-aa-1             |         1 |    NULL |
   +--------------------------------------+--------------------------+-----------+---------+
   ```
   ---
   
   ### Test 1 (user accounts)
   
   - `id`: returns the statement scoped to the owning account when the caller has access to it, and an error when it does not.
      ```sh
   	(u1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46531524,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 5.69112164,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(u1) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	🙈 Error: (HTTP 531, error code 4365) Caller does not have permission to operate with provided resource.
      ```
   
   - `accountid`: returns the statement scoped to the provided account if accessible, or an empty list otherwise.
      ```sh
   	(u1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=2f49212d-d6d5-437b-800d-a7bb4a8def4b (u1)
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46531524,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 5.69112164,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(u1) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=2f49212d-d6d5-437b-800d-a7bb4a8def4b (u1)
   	{
   	  "quotaresourcestatement": {
   	    "items": [],
   	    "totalquota": 0,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
      ```
   
   - `projectid`: returns the statement scoped to the provided project if accessible, or an exception otherwise.
   	```sh
   	(u1) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 projectid=c1ce41c4-7b01-4386-8264-479db5ace0bc
   	🙈 Error: (HTTP 432, error code 9999) The API [quotaResourceStatement] does not exist or is not available for this account/user in project [c1ce41c4-7b01-4386-8264-479db5ace0bc].
   
   	(ur) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 projectid=c1ce41c4-7b01-4386-8264-479db5ace0bc
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b14100c6-d9f6-450e-87a2-0833bb45e5f8",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42573923,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 22.20631686,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   
   - `isrecursive`: ignored for user accounts.
   	```sh
   	(ur) 🐱 > quota resourcestatement id=db0db635-df4d-42bb-9aca-19cc3d986ca0 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=true
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b029e8b8-e539-4d1a-906d-3d4f2fb36b82",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46247754,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 18.9019186,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(ur) 🐱 > quota resourcestatement id=db0db635-df4d-42bb-9aca-19cc3d986ca0 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=false
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b029e8b8-e539-4d1a-906d-3d4f2fb36b82",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46247754,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 18.9019186,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   ---
   
   ### Test 2 (domain admins)
   
   - `id`: returns the statement scoped to the caller's domain.
      ```sh
   	(d1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46531524,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 14.60737768,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(d1) 🐱 > quota resourcestatement id=db0db635-df4d-42bb-9aca-19cc3d986ca0 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42775528,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 25.15400928,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(d1) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [],
   	    "totalquota": 0,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
      ```
   
   - `accountid`: returns the statement scoped to the provided account if accessible, or an exception otherwise.
      ```sh
   	(d1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=2f49212d-d6d5-437b-800d-a7bb4a8def4b
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46531524,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 11.44631141,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(d1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=feaffae2-7ba4-45dc-b46f-20ae86192685 
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "feaffae2-7ba4-45dc-b46f-20ae86192685",
   		"enddate": "2026-05-26T20:59:59-0300",
   		"quotaconsumed": 3.16106627,
   		"startdate": "2026-05-25T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      }
   	    ],
   	    "totalquota": 3.16106627,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(d1) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=f684da1a-f84b-11f0-8ace-32e0826870ba
   	🙈 Error: (HTTP 531, error code 4365) Caller does not have permission to operate with provided resource.
      ```
   
   - `projectid`: returns the statement scoped to the provided project if accessible, or an exception otherwise.
   	```sh
   	(d1) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 projectid=c1ce41c4-7b01-4386-8264-479db5ace0bc
   	🙈 Error: (HTTP 531, error code 4365) Account Account [{"accountName":"d1","id":5,"uuid":"feaffae2-7ba4-45dc-b46f-20ae86192685"}] does not have permission to operate within domain id=de3f3dfb-f84b-11f0-8ace-32e0826870ba
   
   	(dr) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 projectid=c1ce41c4-7b01-4386-8264-479db5ace0bc
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b14100c6-d9f6-450e-87a2-0833bb45e5f8",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42573923,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.76108809,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   
   - `isrecursive`: allows domain admins to generate the statement including usage records of subdomains.
   	```sh
   	(dr) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=true
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 52.70616739,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(dr) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=false
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 33.79573569,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   
   ---
   
   ### Test 3 (root admins)
   
   - `id`: returns the statement of any resource without limiting.
      ```sh
   	(admin) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.76534465,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(admin) 🐱 > quota resourcestatement id=ab6b1ced-d36e-4436-aad2-e78e06005350 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "feaffae2-7ba4-45dc-b46f-20ae86192685",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42801677,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.76291791,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(admin) 🐱 > quota resourcestatement id=db0db635-df4d-42bb-9aca-19cc3d986ca0 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42775528,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.75638356,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(admin) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b029e8b8-e539-4d1a-906d-3d4f2fb36b82",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42670996,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.7583256,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
      ```
   
   - `accountid`: returns the statement scoped to the provided account.
      ```sh
   	(admin) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=2f49212d-d6d5-437b-800d-a7bb4a8def4b
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "2f49212d-d6d5-437b-800d-a7bb4a8def4b",
   		"enddate": "2026-05-24T20:59:59-0300",
   		"quotaconsumed": 2.46531524,
   		"startdate": "2026-05-23T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 11.44631141,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(admin) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=feaffae2-7ba4-45dc-b46f-20ae86192685
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "feaffae2-7ba4-45dc-b46f-20ae86192685",
   		"enddate": "2026-05-26T20:59:59-0300",
   		"quotaconsumed": 3.16106627,
   		"startdate": "2026-05-25T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      }
   	    ],
   	    "totalquota": 3.16106627,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   
   	(admin) 🐱 > quota resourcestatement id=53c791d2-ac8f-4acb-9246-3a2b9eb354ea startdate=2026-01-01 enddate=2027-01-01 usagetype=1 accountid=f684da1a-f84b-11f0-8ace-32e0826870ba
   	{
   	  "quotaresourcestatement": {
   	    "items": [],
   	    "totalquota": 0,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
      ```
   
   - `projectid`: returns the statement scoped to the provided project.
   	```sh
   	(admin) 🐱 > quota resourcestatement id=6d7b3c73-7f06-4f23-9210-3af5889790d1 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 projectid=c1ce41c4-7b01-4386-8264-479db5ace0bc
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "b14100c6-d9f6-450e-87a2-0833bb45e5f8",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42573923,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 39.76108809,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   
   - `isrecursive`: allows admins to generate the statement including usage records of subdomains.
   	```sh
   	(admin) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 33.79573569,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(admin) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=true
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 52.70616739,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	(admin) 🐱 > quota resourcestatement id=e4e91818-cbb5-401a-bb42-35d976ea4e01 startdate=2026-01-01 enddate=2027-01-01 usagetype=1 isrecursive=false
   	{
   	  "quotaresourcestatement": {
   	    "items": [
   	      {
   		"accountid": "f684da1a-f84b-11f0-8ace-32e0826870ba",
   		"enddate": "2026-05-21T20:59:59-0300",
   		"quotaconsumed": 1.42880073,
   		"startdate": "2026-05-20T21:00:00-0300",
   		"tariffid": "2b9671f8-a0ec-4127-bcc8-69413375c3c6",
   		"tariffname": "RUNNING_VM"
   	      },
   	      ...
   	    ],
   	    "totalquota": 33.79573569,
   	    "unit": "Compute*Month",
   	    "usagename": "RUNNING_VM"
   	  }
   	}
   	```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4559892920

   @winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with  no SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4554509676

   @winterhazel , I can review, but you probably have someone more knowledgeable to look at this...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel merged PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4558179550

   Packaging result [SF]: ✖️ el8 ✖️ el9  ✖️ debian ✖️ suse15. SL-JID 18067


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "gp-santos (via GitHub)" <gi...@apache.org>.
gp-santos commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3343895123


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/dao/QuotaUsageJoinDaoImpl.java:
##########
@@ -71,11 +71,13 @@ private void prepareQuotaUsageSearchBuilder(SearchBuilder<QuotaUsageJoinVO> sear
     }
 
     @Override
-    public List<QuotaUsageJoinVO> findQuotaUsage(Long accountId, Long domainId, Integer usageType, Long resourceId, Long networkId, Long offeringId, Date startDate, Date endDate, Long tariffId) {
+    public List<QuotaUsageJoinVO> findQuotaUsage(Long accountId, List<Long> domainIds, Integer usageType, Long resourceId, Long networkId, Long offeringId, Date startDate, Date endDate, Long tariffId) {
         SearchCriteria<QuotaUsageJoinVO> sc = tariffId == null ? searchQuotaUsages.create() : searchQuotaUsagesJoinTariffUsages.create();
 
         sc.setParametersIfNotNull("accountId", accountId);
-        sc.setParametersIfNotNull("domainId", domainId);
+        if (domainIds != null) {

Review Comment:
   Maybe `!ObjectUtils.isEmpty()`? Just in case someone uses it with an empty list.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4690688240

   Test failures are unrelated, so merging


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3396034284


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java:
##########
@@ -1158,6 +1135,185 @@ public QuotaValidateActivationRuleResponse validateActivationRule(QuotaValidateA
         return createValidateActivationRuleResponse(activationRule, quotaName, false, message);
     }
 
+    @Override
+    public QuotaResourceStatementResponse createQuotaResourceStatement(QuotaResourceStatementCmd cmd) {
+        String resourceUuid = cmd.getId();
+        Integer usageType = cmd.getUsageType();
+        Date startDate = cmd.getStartDate();
+        Date endDate = cmd.getEndDate();
+
+        if (startDate.after(endDate)) {
+            throw new InvalidParameterValueException(String.format("The start date [%s] must be before the end date [%s].", startDate, endDate));
+        }
+
+        InternalIdentity resource = retrieveResource(resourceUuid, usageType);
+        if (resource == null) {
+            logger.error("Could not find resource [{}] of type [{}]. Returning an empty list.", resourceUuid, usageType);
+            return createQuotaResourceStatementResponse(resourceUuid, usageType,  new ArrayList<>(), new BigDecimal(0));
+        }
+
+        long id = resource.getId();
+
+        Long currentOwnerId = null;
+        if (resource instanceof ControlledEntity) {
+            currentOwnerId = ((ControlledEntity) resource).getAccountId();
+        }
+        Long accountId = getAccountIdForQuotaStatement(cmd.getEntityOwnerId(), currentOwnerId);
+        Pair<Long, List<Long>> baseDomainAndFilteredDomains = getDomainIdsForQuotaStatement(accountId, cmd.getDomainId(), cmd.isRecursive());
+
+        Long resourceId = null;
+        Long networkId = null;
+        Long offeringId = null;
+
+        switch (usageType) {
+            case UsageTypes.NETWORK_OFFERING:
+            case UsageTypes.BACKUP:
+                offeringId = id;
+                break;
+            case UsageTypes.NETWORK_BYTES_RECEIVED:
+            case UsageTypes.NETWORK_BYTES_SENT:
+                networkId = id;
+                break;
+            default:
+                resourceId = id;
+        }
+
+        logger.debug("Attempting to find quota usages with parameters usage type [{}], usage id [{}], network id [{}], offering id [{}], and between [{}] and [{}].",
+                usageType, resourceId, networkId, offeringId, startDate, endDate);
+
+        List<QuotaUsageJoinVO> quotaUsageJoinList = quotaUsageJoinDao.findQuotaUsage(accountId, baseDomainAndFilteredDomains.second(), usageType, resourceId, networkId, offeringId, startDate, endDate, null);
+
+        logger.debug("Found [{}] quota usages using as parameter usage type [{}], usage id [{}], network id [{}], offering id [{}], and between [{}] and [{}].",
+                quotaUsageJoinList.size(), usageType, resourceId, networkId, offeringId, startDate, endDate);
+
+        List<QuotaResourceStatementItemResponse> quotaResourceStatementItemResponseList = new ArrayList<>();
+        BigDecimal totalQuotaUsed = new BigDecimal(0);
+        List<QuotaTariffVO> quotaTariffs = _quotaTariffDao.listQuotaTariffs(null, null, usageType, null, null, true, null, null).first();
+
+        for (QuotaUsageJoinVO quotaUsageJoin : quotaUsageJoinList) {
+            Account account = _accountMgr.getAccount(quotaUsageJoin.getAccountId());
+            String accountUuid = account.getUuid();
+
+            List<QuotaTariffUsageVO> quotaTariffUsageList = quotaTariffUsageDao.listQuotaTariffUsages(quotaUsageJoin.getId());
+            logger.debug("Found [{}] quota tariff usages associated to the quota usage [{}] of resource [{}] and type [{}] between [{}] and [{}].",
+                    quotaTariffUsageList.size(), quotaUsageJoin, resourceUuid, usageType, startDate, endDate);
+            for (QuotaTariffUsageVO quotaTariffUsage: quotaTariffUsageList) {
+                quotaResourceStatementItemResponseList.add(createQuotaResourceStatementItemResponse(quotaTariffUsage, quotaTariffs, quotaUsageJoin.getStartDate(),
+                        quotaUsageJoin.getEndDate(), accountUuid));
+                totalQuotaUsed = totalQuotaUsed.add(quotaTariffUsage.getQuotaUsed());
+            }
+        }
+        logger.debug("The total quota used of type [{}] between [{}] and [{}] for the resource [{}] was [{}].", usageType, startDate, endDate, resourceUuid, totalQuotaUsed);
+
+        return createQuotaResourceStatementResponse(resourceUuid, usageType, quotaResourceStatementItemResponseList, totalQuotaUsed);
+    }
+
+    protected Long getAccountIdForQuotaStatement(long providedAccountId, Long fallbackAccountId) {
+        Account caller = CallContext.current().getCallingAccount();
+
+        if (providedAccountId != -1L) {
+            Account account = _accountDao.findByIdIncludingRemoved(providedAccountId);
+            _accountMgr.checkAccess(caller, null, false, account);
+            logger.debug("Limiting the Quota resource statement for the provided Account [{}].", providedAccountId);
+            return providedAccountId;
+        }
+
+        Account.Type callerType = caller.getType();
+        if (Account.Type.ADMIN.equals(callerType) || Account.Type.DOMAIN_ADMIN.equals(callerType)) {
+            logger.debug("Not limiting the Quota resource statement for a specific Account, as no specific Account was provided and the caller is either an admin or domain admin.");
+            return null;
+        }
+
+        if (fallbackAccountId != null) {
+            Account fallbackAccount = _accountDao.findByIdIncludingRemoved(fallbackAccountId);
+            _accountMgr.checkAccess(caller, null, false, fallbackAccount);
+            logger.debug("Limiting the Quota statement for the fallback Account [{}], as no specific Account was provided.", fallbackAccountId);
+            return fallbackAccountId;
+        }
+
+        logger.debug("Limiting the Quota resource statement for the calling account, as no specific Account was provided and no fallback account was provided.");
+        return caller.getAccountId();
+    }
+
+    protected Pair<Long, List<Long>> getDomainIdsForQuotaStatement(Long finalAccountId, Long providedDomainId, boolean isRecursive) {
+        if (finalAccountId != null) {
+            // Access to the provided account has already been validated
+            logger.debug("Not limiting the Quota statement for a specific Domain, as we are already limiting by Account.");
+            return new Pair<>(null, null);
+        }
+
+        // User accounts will have already been limited to themselves
+        Account caller = CallContext.current().getCallingAccount();
+        Long domainId = providedDomainId;
+
+        if (domainId != null) {
+            Domain domain = domainDao.findByIdIncludingRemoved(domainId);
+            _accountMgr.checkAccess(caller, domain);
+            logger.debug("Limiting the Quota statement for the provided Domain [{}].", domainId);
+        }
+        if (domainId == null) {

Review Comment:
   I'm converting it to an `else`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4673961792

   @Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4646255639

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4544795846

   Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18042


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3319152214


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java:
##########
@@ -20,7 +20,6 @@
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.api.ACL;

Review Comment:
   @DaanHoogland the access validations were moved to `QuotaResponseBuilderImpl#getAccountIdForQuotaStatement` and `QuotaResponseBuilderImpl#getDomainIdsForQuotaStatement`. These methods centralize how `quotaStatement` and `quotaResourceStatement` choose what to generate the statement for and how they perform the permission checking.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4673850127

   @DaanHoogland @weizhouapache @sureshanaparti @Pearl1594 can we run the CI here?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4559880874

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4544407293

   @DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with  no SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3316109034


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaStatementResponse.java:
##########
@@ -31,11 +31,11 @@ public class QuotaStatementResponse  extends BaseResponse {
     @Param(description = "ID of the Account.")
     private String accountId;
 
-    @SerializedName(ApiConstants.ACCOUNT)
+    @SerializedName(ApiConstants.ACCOUNT_NAME)
     @Param(description = "Name of the Account.")
     private String accountName;
 
-    @SerializedName(ApiConstants.DOMAIN)
+    @SerializedName(ApiConstants.DOMAIN_ID)

Review Comment:
   also a backwards incompatability?



##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java:
##########
@@ -20,7 +20,6 @@
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.api.ACL;

Review Comment:
   so some access validation is being skipped now. Wat is the ratio on this?



##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaStatementResponse.java:
##########
@@ -31,11 +31,11 @@ public class QuotaStatementResponse  extends BaseResponse {
     @Param(description = "ID of the Account.")
     private String accountId;
 
-    @SerializedName(ApiConstants.ACCOUNT)
+    @SerializedName(ApiConstants.ACCOUNT_NAME)

Review Comment:
   this seem a backwards incompatability, is it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4652803521

   Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18196


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4680171967

   <b>[SF] Trillian test result (tid-16283)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 53597 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13236-t16283-kvm-ol8.zip
   Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4680851493

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4652362413

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4687759208

   <b>[SF] Trillian test result (tid-16289)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 52925 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13236-t16289-kvm-ol8.zip
   Smoke tests completed. 150 look OK, 1 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_router_dhcphosts | `Failure` | 21.20 | test_router_dhcphosts.py
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4673949428

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4558057318

   @winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with  no SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4544397887

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4536358284

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "GaOrtiga (via GitHub)" <gi...@apache.org>.
GaOrtiga commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3313062168


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -348,31 +365,41 @@ protected boolean shouldCalculateUsageRecord(AccountVO accountVO, UsageVO usageR
         return true;
     }
 
-    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(List<Pair<UsageVO, QuotaUsageVO>> pairsUsageAndQuotaUsage) {
-        List<QuotaUsageVO> quotaUsages = new ArrayList<>();
+    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(Map<UsageVO, Pair<QuotaUsageVO, List<QuotaTariffUsageVO>>> mapUsageAndQuotaTariffUsage) {
+        List<QuotaUsageVO> quotaUsages = new ArrayList<>(); // TODO: isso tem que ser em uma transação

Review Comment:
   @winterhazel Has this been addressed? or can we just delete the comment



##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -348,31 +365,41 @@ protected boolean shouldCalculateUsageRecord(AccountVO accountVO, UsageVO usageR
         return true;
     }
 
-    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(List<Pair<UsageVO, QuotaUsageVO>> pairsUsageAndQuotaUsage) {
-        List<QuotaUsageVO> quotaUsages = new ArrayList<>();
+    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(Map<UsageVO, Pair<QuotaUsageVO, List<QuotaTariffUsageVO>>> mapUsageAndQuotaTariffUsage) {
+        List<QuotaUsageVO> quotaUsages = new ArrayList<>(); // TODO: isso tem que ser em uma transação

Review Comment:
   @winterhazel Has this been addressed? or can we just delete the comment?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4652369625

   @winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with  no SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4681303488

   @Pearl1594 also asking to run the CI here one last time before the merge :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "gp-santos (via GitHub)" <gi...@apache.org>.
gp-santos commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3343895123


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/dao/QuotaUsageJoinDaoImpl.java:
##########
@@ -71,11 +71,13 @@ private void prepareQuotaUsageSearchBuilder(SearchBuilder<QuotaUsageJoinVO> sear
     }
 
     @Override
-    public List<QuotaUsageJoinVO> findQuotaUsage(Long accountId, Long domainId, Integer usageType, Long resourceId, Long networkId, Long offeringId, Date startDate, Date endDate, Long tariffId) {
+    public List<QuotaUsageJoinVO> findQuotaUsage(Long accountId, List<Long> domainIds, Integer usageType, Long resourceId, Long networkId, Long offeringId, Date startDate, Date endDate, Long tariffId) {
         SearchCriteria<QuotaUsageJoinVO> sc = tariffId == null ? searchQuotaUsages.create() : searchQuotaUsagesJoinTariffUsages.create();
 
         sc.setParametersIfNotNull("accountId", accountId);
-        sc.setParametersIfNotNull("domainId", domainId);
+        if (domainIds != null) {

Review Comment:
   Maybe `!ObjectUtils.isEmpty()`? Just in case someone uses it with an empty list.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4553302317

   <b>[SF] Trillian test result (tid-16186)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 55395 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13236-t16186-kvm-ol8.zip
   Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4557243016

   > @winterhazel , I can review, but you probably have someone more knowledgeable to look at this...
   
   @DaanHoogland I already asked some people that are familiar with Quota to review this one, but feel free to review as well if you want to. Your reviews would still be appreciated :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "GaOrtiga (via GitHub)" <gi...@apache.org>.
GaOrtiga commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3313062168


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -348,31 +365,41 @@ protected boolean shouldCalculateUsageRecord(AccountVO accountVO, UsageVO usageR
         return true;
     }
 
-    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(List<Pair<UsageVO, QuotaUsageVO>> pairsUsageAndQuotaUsage) {
-        List<QuotaUsageVO> quotaUsages = new ArrayList<>();
+    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(Map<UsageVO, Pair<QuotaUsageVO, List<QuotaTariffUsageVO>>> mapUsageAndQuotaTariffUsage) {
+        List<QuotaUsageVO> quotaUsages = new ArrayList<>(); // TODO: isso tem que ser em uma transação

Review Comment:
   @winterhazel Does this still need to be addressed? or can we just delete the comment



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3313096236


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -348,31 +365,41 @@ protected boolean shouldCalculateUsageRecord(AccountVO accountVO, UsageVO usageR
         return true;
     }
 
-    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(List<Pair<UsageVO, QuotaUsageVO>> pairsUsageAndQuotaUsage) {
-        List<QuotaUsageVO> quotaUsages = new ArrayList<>();
+    protected List<QuotaUsageVO> persistUsagesAndQuotaUsagesAndRetrievePersistedQuotaUsages(Map<UsageVO, Pair<QuotaUsageVO, List<QuotaTariffUsageVO>>> mapUsageAndQuotaTariffUsage) {
+        List<QuotaUsageVO> quotaUsages = new ArrayList<>(); // TODO: isso tem que ser em uma transação

Review Comment:
   Not addressed yet, good catch. I almost forgot to implement this one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4680869590

   @winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with  no SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4681278672

   Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18229


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4681325069

   @Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "erikbocks (via GitHub)" <gi...@apache.org>.
erikbocks commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3395483446


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java:
##########
@@ -1158,6 +1135,185 @@ public QuotaValidateActivationRuleResponse validateActivationRule(QuotaValidateA
         return createValidateActivationRuleResponse(activationRule, quotaName, false, message);
     }
 
+    @Override
+    public QuotaResourceStatementResponse createQuotaResourceStatement(QuotaResourceStatementCmd cmd) {
+        String resourceUuid = cmd.getId();
+        Integer usageType = cmd.getUsageType();
+        Date startDate = cmd.getStartDate();
+        Date endDate = cmd.getEndDate();
+
+        if (startDate.after(endDate)) {
+            throw new InvalidParameterValueException(String.format("The start date [%s] must be before the end date [%s].", startDate, endDate));
+        }
+
+        InternalIdentity resource = retrieveResource(resourceUuid, usageType);
+        if (resource == null) {
+            logger.error("Could not find resource [{}] of type [{}]. Returning an empty list.", resourceUuid, usageType);
+            return createQuotaResourceStatementResponse(resourceUuid, usageType,  new ArrayList<>(), new BigDecimal(0));
+        }
+
+        long id = resource.getId();
+
+        Long currentOwnerId = null;
+        if (resource instanceof ControlledEntity) {
+            currentOwnerId = ((ControlledEntity) resource).getAccountId();
+        }
+        Long accountId = getAccountIdForQuotaStatement(cmd.getEntityOwnerId(), currentOwnerId);
+        Pair<Long, List<Long>> baseDomainAndFilteredDomains = getDomainIdsForQuotaStatement(accountId, cmd.getDomainId(), cmd.isRecursive());
+
+        Long resourceId = null;
+        Long networkId = null;
+        Long offeringId = null;
+
+        switch (usageType) {
+            case UsageTypes.NETWORK_OFFERING:
+            case UsageTypes.BACKUP:
+                offeringId = id;
+                break;
+            case UsageTypes.NETWORK_BYTES_RECEIVED:
+            case UsageTypes.NETWORK_BYTES_SENT:
+                networkId = id;
+                break;
+            default:
+                resourceId = id;
+        }
+
+        logger.debug("Attempting to find quota usages with parameters usage type [{}], usage id [{}], network id [{}], offering id [{}], and between [{}] and [{}].",
+                usageType, resourceId, networkId, offeringId, startDate, endDate);
+
+        List<QuotaUsageJoinVO> quotaUsageJoinList = quotaUsageJoinDao.findQuotaUsage(accountId, baseDomainAndFilteredDomains.second(), usageType, resourceId, networkId, offeringId, startDate, endDate, null);
+
+        logger.debug("Found [{}] quota usages using as parameter usage type [{}], usage id [{}], network id [{}], offering id [{}], and between [{}] and [{}].",
+                quotaUsageJoinList.size(), usageType, resourceId, networkId, offeringId, startDate, endDate);
+
+        List<QuotaResourceStatementItemResponse> quotaResourceStatementItemResponseList = new ArrayList<>();
+        BigDecimal totalQuotaUsed = new BigDecimal(0);
+        List<QuotaTariffVO> quotaTariffs = _quotaTariffDao.listQuotaTariffs(null, null, usageType, null, null, true, null, null).first();
+
+        for (QuotaUsageJoinVO quotaUsageJoin : quotaUsageJoinList) {
+            Account account = _accountMgr.getAccount(quotaUsageJoin.getAccountId());
+            String accountUuid = account.getUuid();
+
+            List<QuotaTariffUsageVO> quotaTariffUsageList = quotaTariffUsageDao.listQuotaTariffUsages(quotaUsageJoin.getId());
+            logger.debug("Found [{}] quota tariff usages associated to the quota usage [{}] of resource [{}] and type [{}] between [{}] and [{}].",
+                    quotaTariffUsageList.size(), quotaUsageJoin, resourceUuid, usageType, startDate, endDate);
+            for (QuotaTariffUsageVO quotaTariffUsage: quotaTariffUsageList) {
+                quotaResourceStatementItemResponseList.add(createQuotaResourceStatementItemResponse(quotaTariffUsage, quotaTariffs, quotaUsageJoin.getStartDate(),
+                        quotaUsageJoin.getEndDate(), accountUuid));
+                totalQuotaUsed = totalQuotaUsed.add(quotaTariffUsage.getQuotaUsed());
+            }
+        }
+        logger.debug("The total quota used of type [{}] between [{}] and [{}] for the resource [{}] was [{}].", usageType, startDate, endDate, resourceUuid, totalQuotaUsed);
+
+        return createQuotaResourceStatementResponse(resourceUuid, usageType, quotaResourceStatementItemResponseList, totalQuotaUsed);
+    }
+
+    protected Long getAccountIdForQuotaStatement(long providedAccountId, Long fallbackAccountId) {
+        Account caller = CallContext.current().getCallingAccount();
+
+        if (providedAccountId != -1L) {
+            Account account = _accountDao.findByIdIncludingRemoved(providedAccountId);
+            _accountMgr.checkAccess(caller, null, false, account);
+            logger.debug("Limiting the Quota resource statement for the provided Account [{}].", providedAccountId);
+            return providedAccountId;
+        }
+
+        Account.Type callerType = caller.getType();
+        if (Account.Type.ADMIN.equals(callerType) || Account.Type.DOMAIN_ADMIN.equals(callerType)) {
+            logger.debug("Not limiting the Quota resource statement for a specific Account, as no specific Account was provided and the caller is either an admin or domain admin.");
+            return null;
+        }
+
+        if (fallbackAccountId != null) {
+            Account fallbackAccount = _accountDao.findByIdIncludingRemoved(fallbackAccountId);
+            _accountMgr.checkAccess(caller, null, false, fallbackAccount);
+            logger.debug("Limiting the Quota statement for the fallback Account [{}], as no specific Account was provided.", fallbackAccountId);
+            return fallbackAccountId;
+        }
+
+        logger.debug("Limiting the Quota resource statement for the calling account, as no specific Account was provided and no fallback account was provided.");
+        return caller.getAccountId();
+    }
+
+    protected Pair<Long, List<Long>> getDomainIdsForQuotaStatement(Long finalAccountId, Long providedDomainId, boolean isRecursive) {
+        if (finalAccountId != null) {
+            // Access to the provided account has already been validated
+            logger.debug("Not limiting the Quota statement for a specific Domain, as we are already limiting by Account.");
+            return new Pair<>(null, null);
+        }
+
+        // User accounts will have already been limited to themselves
+        Account caller = CallContext.current().getCallingAccount();
+        Long domainId = providedDomainId;
+
+        if (domainId != null) {
+            Domain domain = domainDao.findByIdIncludingRemoved(domainId);
+            _accountMgr.checkAccess(caller, domain);
+            logger.debug("Limiting the Quota statement for the provided Domain [{}].", domainId);
+        }
+        if (domainId == null) {

Review Comment:
   ```suggestion
           }
           
           if (domainId == null) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4681314822

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4536444338

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/13236?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 3.51%. Comparing base ([`a0aafe2`](https://app.codecov.io/gh/apache/cloudstack/commit/a0aafe2fa73132f08d7ae67b302d2e1fa6d02068?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b0ba9a1`](https://app.codecov.io/gh/apache/cloudstack/commit/b0ba9a11f553f515157b55663be0a219f57dde11?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (a0aafe2) and HEAD (b0ba9a1). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (a0aafe2) | HEAD (b0ba9a1) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               main   #13236       +/-   ##
   =============================================
   - Coverage     18.10%    3.51%   -14.59%     
   =============================================
     Files          6037      464     -5573     
     Lines        542933    40157   -502776     
     Branches      66487     7559    -58928     
   =============================================
   - Hits          98283     1413    -96870     
   + Misses       433602    38554   -395048     
   + Partials      11048      190    -10858     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/13236/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/13236/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.51% <ø> (ø)` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/13236/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/13236?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4560112783

   Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18069


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4558053181

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4546795875

   @DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#issuecomment-4546764636

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Quota resource statement API [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #13236:
URL: https://github.com/apache/cloudstack/pull/13236#discussion_r3319209541


##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaStatementResponse.java:
##########
@@ -31,11 +31,11 @@ public class QuotaStatementResponse  extends BaseResponse {
     @Param(description = "ID of the Account.")
     private String accountId;
 
-    @SerializedName(ApiConstants.ACCOUNT)
+    @SerializedName(ApiConstants.ACCOUNT_NAME)

Review Comment:
   @DaanHoogland yes, this is a backwards incompatibility. As a good portion of the Quota APIs are being worked on this release, I thought it was a good opportunity to standardize the field naming to match the other APIs. This change was done considering that:
   
   - There probably are not many people using Quota for billing-related processes in previous versions due to both lack of flexibility on assigning values and lack of documentation on how to use the activation rules (the latter will be addressed in 4.23).
   - Either `accountname` + `domainid` or `accountid` must be provided to the API, so operators already know which account/domain the statement belongs to. Therefore, I find it unlikely that external integrations rely on this field. The UI does not use it either.
   - As the Quota plugin is planned to receive in this release lots of new functionality that will make it more reliable for external integrations, I expect that existing integrations will be updated. And just renaming a field from the response is a very simple update.



##########
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaStatementResponse.java:
##########
@@ -31,11 +31,11 @@ public class QuotaStatementResponse  extends BaseResponse {
     @Param(description = "ID of the Account.")
     private String accountId;
 
-    @SerializedName(ApiConstants.ACCOUNT)
+    @SerializedName(ApiConstants.ACCOUNT_NAME)
     @Param(description = "Name of the Account.")
     private String accountName;
 
-    @SerializedName(ApiConstants.DOMAIN)
+    @SerializedName(ApiConstants.DOMAIN_ID)

Review Comment:
   See https://github.com/apache/cloudstack/pull/13236#discussion_r3319209541



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org