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>
   
   
![image](https://github.com/user-attachments/assets/51324eb2-f3ae-4503-90e9-ea51f9d6acd5)
   </details>
   
   <details>
   <summary>Tariffs list view</summary>
   
   
![image](https://github.com/user-attachments/assets/86dfde07-9977-4b48-b620-1226bb3fae1d)
   </details>
   
   <details>
   <summary>Create form</summary>
   
   
![image](https://github.com/user-attachments/assets/6ef7ad61-11a1-4634-b437-e19e9e1fc97d)
   </details>
   
   <details>
   <summary>Update form</summary>
   
   
![image](https://github.com/user-attachments/assets/d5ef51ff-55c4-4293-8571-e11b420c6a95)
   </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>
   
   
![image](https://github.com/user-attachments/assets/199527da-a3cf-4bc1-a423-f70247fe39d7)
   </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>
   
   
![image](https://github.com/user-attachments/assets/6ef7ad61-11a1-4634-b437-e19e9e1fc97d)
   </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>
   
   
![image](https://github.com/user-attachments/assets/ecc842f5-e583-4f7f-9810-75a8c68761fc)
   </details>
   
   <details>
   <summary>Tariff details</summary>
   
   
![image](https://github.com/user-attachments/assets/b32b46f4-9e1e-4fa5-97fb-570f5b66613c)
   </details>
   
   ###### Creation of a tariff filling all fields
   <details>
   <summary>Creation form</summary>
   
   
![image](https://github.com/user-attachments/assets/c6794591-39f1-47d7-8f69-3dc0d880f7d4)
   </details>
   
   <details>
   <summary>Tariffs list view</summary>
   
   
![image](https://github.com/user-attachments/assets/86dfde07-9977-4b48-b620-1226bb3fae1d)
   </details>
   
   <details>
   <summary>Tariffs details</summary>
   
   
![image](https://github.com/user-attachments/assets/51324eb2-f3ae-4503-90e9-ea51f9d6acd5)
   </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>
   
   
![image](https://github.com/user-attachments/assets/d5ef51ff-55c4-4293-8571-e11b420c6a95)
   </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>
   
   
![image](https://github.com/user-attachments/assets/203686d0-a5ef-4652-9940-b7e080393127)
   </details>
   
   <details>
   <summary>HTTP request payload</summary>
   
   
![image](https://github.com/user-attachments/assets/dd984b4c-b310-47ff-93b6-456fbd52abd8)
   </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>
   
   
![image](https://github.com/user-attachments/assets/d0770cba-188b-40af-be88-ae7de6933558)
   </details>
   
   <details>
   <summary>Filtering by name</summary>
   
   
![image](https://github.com/user-attachments/assets/de4daec0-804f-4ccb-8786-045558d2c738)
   </details>
    
   <details>
   <summary>Filtering the removed ones</summary>
   
   
![image](https://github.com/user-attachments/assets/3d9e600e-97f3-4511-9387-f2587ef3510d)
   </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

Reply via email to