bernardodemarco opened a new pull request, #9225: URL: https://github.com/apache/cloudstack/pull/9225
### Description This PR proposes some improvements to quota tariffs APIs and UI. Two parameters have been added to the `quotaTariffList` API: `id` and `listonlyremoved`. The first one refers to the tariff's ID, and the other to a flag that indicates whether only the removed tariffs will be listed. The `keyword` API parameter has also been changed in order to filter tariffs that contain a given keyword in their names. Additionally, a validation has been added to check if the calling user has access to the tariff's activation rules. They will have access if they have permission to create or update tariffs. The quota tariff's UI has also been refactored. Now, more fields of the `quotaTariffList` response are displayed, and the operator can easily create, edit and filter tariffs. To filter tariffs by usage type, the `listUsageType` API response has been refactored, adding the name of the usage type in uppercase letters, separated by underscores, such as `ALLOCATED_VM`. ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] 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) - [X] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] build/CI ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [X] Major - [ ] Minor ### Screenshots: <details> <summary>Tariffs details</summary>  </details> <details> <summary>Tariffs list view</summary>  </details> <details> <summary>Create form</summary>  </details> <details> <summary>Update form</summary>  </details> ### How Has This Been Tested? #### `listUsageTypes` API I logged in CloudMonkey with a root admin user and I executed the `listUsageTypes` command, receiving the following response. <details> <summary><code>listUsageTypes</code></summary> ```bash > listUsageTypes { "count": 25, "usagetype": [ { "description": "Running Vm Usage", "id": 1, "name": "RUNNING_VM" }, { "description": "Allocated Vm Usage", "id": 2, "name": "ALLOCATED_VM" }, { "description": "IP Address Usage", "id": 3, "name": "IP_ADDRESS" }, { "description": "Network Usage (Bytes Sent)", "id": 4, "name": "NETWORK_BYTES_SENT" }, { "description": "Network Usage (Bytes Received)", "id": 5, "name": "NETWORK_BYTES_RECEIVED" }, { "description": "Volume Usage", "id": 6, "name": "VOLUME" }, { "description": "Template Usage", "id": 7, "name": "TEMPLATE" }, { "description": "ISO Usage", "id": 8, "name": "ISO" }, { "description": "Snapshot Usage", "id": 9, "name": "SNAPSHOT" }, { "description": "Security Group Usage", "id": 10, "name": "SECURITY_GROUP" }, { "description": "Load Balancer Usage", "id": 11, "name": "LOAD_BALANCER_POLICY" }, { "description": "Port Forwarding Usage", "id": 12, "name": "PORT_FORWARDING_RULE" }, { "description": "Network Offering Usage", "id": 13, "name": "NETWORK_OFFERING" }, { "description": "VPN users usage", "id": 14, "name": "VPN_USERS" }, { "description": "VM Disk usage(I/O Read)", "id": 21, "name": "VM_DISK_IO_READ" }, { "description": "VM Disk usage(I/O Write)", "id": 22, "name": "VM_DISK_IO_WRITE" }, { "description": "VM Disk usage(Bytes Read)", "id": 23, "name": "VM_DISK_BYTES_READ" }, { "description": "VM Disk usage(Bytes Write)", "id": 24, "name": "VM_DISK_BYTES_WRITE" }, { "description": "VM Snapshot storage usage", "id": 25, "name": "VM_SNAPSHOT" }, { "description": "Volume on secondary storage usage", "id": 26, "name": "VOLUME_SECONDARY" }, { "description": "VM Snapshot on primary storage usage", "id": 27, "name": "VM_SNAPSHOT_ON_PRIMARY" }, { "description": "Backup storage usage", "id": 28, "name": "BACKUP" }, { "description": "Bucket storage usage", "id": 29, "name": "BUCKET" }, { "description": "Network usage", "id": 30, "name": "NETWORK" }, { "description": "VPC usage", "id": 31, "name": "VPC" } ] } ``` </details> As noticed, the `name` field has been added and is being populated as expected. The `id` and `description` fields have not undergone any changes. #### Quota tariffs ##### Tests setup Before testing, I deleted all default tariffs that existed in the database, and I verified that the `quotaTariffList` parameters were being identified correctly. <details> <summary><code>help quotaTariffList</code></summary> ```bash > help quotaTariffList quotaTariffList: Lists all quota tariff plans API Params Type Description ========== ==== =========== enddate date The end date of the quota tariff. The rec ommended format is "yyyy-MM-dd'T'HH:mm:s sZ" (e.g.: "2023-01-01T12:00:00+0100"); however, the following formats are also accepted: "yyyy-MM-dd HH:mm:ss" (e.g.: " 2023-01-01 12:00:00") and "yyyy-MM-dd" ( e.g.: "2023-01-01" - if the time is not added, it will be interpreted as "23:59: 59"). If the recommended format is not u sed, the date will be considered in the server timezone. id string The quota tariff's id. keyword string List by keyword listall boolean False will list only not removed quota ta riffs. If set to true, we will list all, including the removed ones. The default is false. listonlyremoved boolean If set to true, we will list only the rem oved tariffs. The default is false. name string The name of the quota tariff. page integer pagesize integer startdate date The start date of the quota tariff. The r ecommended format is "yyyy-MM-dd'T'HH:mm :ssZ" (e.g.: "2023-01-01T12:00:00+0100") ; however, the following formats are als o accepted: "yyyy-MM-dd HH:mm:ss" (e.g.: "2023-01-01 12:00:00") and "yyyy-MM-dd" (e.g.: "2023-01-01" - if the time is no t added, it will be interpreted as "00:0 0:00"). If the recommended format is not used, the date will be considered in th e server timezone. usagetype integer Usage type of the resource ``` </details> <details> <summary><code>quotaTariffList</code></summary> ```bash > quotaTariffList # no output ``` </details> <details> <summary>Quota tariffs view</summary>  </details> ##### Create quota tariff through UI Once the `Create Quota Tariff` button is clicked, a form is rendered on the screen, with all the available API fields, except for `activationrule`. <details> <summary>Create Quota Tariff form</summary>  </details> ###### Creation of a tariff with only the required values The required fields are name, usage type and value. When creating a tariff with only them, the start date is automatically set to now, and the other fields are populated correctly. <details> <summary>Tariffs list view</summary>  </details> <details> <summary>Tariff details</summary>  </details> ###### Creation of a tariff filling all fields <details> <summary>Creation form</summary>  </details> <details> <summary>Tariffs list view</summary>  </details> <details> <summary>Tariffs details</summary>  </details> --- ##### Update quota tariff through UI When selecting the option to edit a tariff, its description, value, position and end date are populated correctly. <details> <summary>Update form</summary>  </details> ###### Update all fields If at least one field is changed, then the API request to `quotaTariffUpdate` is performed, passing in only the changed values. <details> <summary>Update form</summary>  </details> <details> <summary>HTTP request payload</summary>  </details> ###### Update no fields If there are no changed fields, the API request to `quotaTariffUpdate` is not performed. --- ##### Remove quota tariff through UI When the delete button is clicked, a modal is rendered asking for confirmation. Once it is confirmed, the quota tariff is removed, and its `removed` field is set to the time that the operation was performed. --- ##### Filter tariffs The tariffs can be filtered by name, usage type and whether they have been removed. <details> <summary>Filtering by usage type</summary>  </details> <details> <summary>Filtering by name</summary>  </details> <details> <summary>Filtering the removed ones</summary>  </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-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org