AzureAPI.AzureCalls (azure_billing_dashboard v0.2.0)
This module contains methods to interact with the Azure API. These are private functions that are only called from AzureAPI.VirtualMachineController.
Link to this section Summary
Functions
Computes availability for all virtual machines.
Retrieves cost data for a specific virtual machine from Azure.
Retrives access token from Azure.
Makes a request to get virtual machine data from Azure
Callback implementation for Phoenix.LiveView.render/1.
Makes a request to start a virtual machine
Makes a request to deallocate a virtual machine
Link to this section Functions
get_availability(azure_keys)
Computes availability for all virtual machines.
Pings the CostManagement/prices endpoint with response filters Skips any virtual machine with a capacity only eviction type Compares the maximum price to that obtained from the endpoint
get_azure_cost_data(name, azure_keys)
Retrieves cost data for a specific virtual machine from Azure.
Constructs a body and sends a request to Azure.
For example, needed in the details page
eg -> response = AzureAPI.VirtualMachineController.get_cost_data(vmName). get_cost_data/1 grabs the token from the genserver and sends it to this function along with the vmName
get_token(azure_keys, pid)
Retrives access token from Azure.
Token expires every hour so it buffers a :refresh_token message back to the genserver every 60 minutes.
Returns token
list_azure_machines_and_statuses(azure_keys, pid)
Makes a request to get virtual machine data from Azure
Retrieves the following from /virtualmachines endpoint:
1. Name
2. Hardware Profile
3. OS Type
4. Maximum PriceRetrieves the following from /instanceview endpoint
1. Power StateImportant note for obtaining new attributes:
1. Determine if attribute comes from the list or instanceView endpoint
a. If list, ensure it is parsed into general_info variable
b. If instanceView, ensure it is parsed into the map variable
2. Ensure that the pattern matches in List_VMs.find_and_update_virtual_machines/1
3. Ensure field created in List_VMs.VirtualMachine (virtual_machine.ex)
4. Ensure field is migrated.Makes a callback request to the virtual machine controller to update the above values.
render(assigns)
Callback implementation for Phoenix.LiveView.render/1.
start_azure_machine(name, azure_keys)
Makes a request to start a virtual machine
Endpoint always returns a 202 - Accepted status
Makes no availability checks. Azure will start the machine if conditions are met.
stop_azure_machine(name, azure_keys)
Makes a request to deallocate a virtual machine