summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHentioe <me@bluerain.io>2020-10-30 23:42:56 +0800
committerHentioe <me@bluerain.io>2020-10-30 23:42:56 +0800
commit180657a9825f3c18ec6207d526cf1acf3f26fe56 (patch)
tree784cc1ae68590d26b08771e0f725d908c35b8c4f
parentAdd some APIs to create resources (diff)
Added some resources to delete APIs
-rw-r--r--lib/azure_ex.ex10
-rw-r--r--lib/azure_ex/request.ex8
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/azure_ex.ex b/lib/azure_ex.ex
index 3f4e29e..e580f0d 100644
--- a/lib/azure_ex.ex
+++ b/lib/azure_ex.ex
@@ -12,6 +12,11 @@ defmodule AzureEx do
)
defendpoint(
+ "DeleteVirtualMachines",
+ "DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2020-06-01"
+ )
+
+ defendpoint(
"GetVirtualMachines",
"GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2020-06-01"
)
@@ -50,4 +55,9 @@ defmodule AzureEx do
"CreateOrUpdateSubnets",
"PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}?api-version=2020-05-01"
)
+
+ defendpoint(
+ "DeleteNetworkInterfaces",
+ "DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}?api-version=2020-05-01"
+ )
end
diff --git a/lib/azure_ex/request.ex b/lib/azure_ex/request.ex
index 88763f3..c7b1432 100644
--- a/lib/azure_ex/request.ex
+++ b/lib/azure_ex/request.ex
@@ -5,7 +5,7 @@ defmodule AzureEx.Request do
alias AzureEx.{Config, TokenHosting}
- @type method :: :get | :post | :put
+ @type method :: :get | :post | :put | :delete
@type data :: map
@type result :: any
@type error :: any
@@ -55,4 +55,10 @@ defmodule AzureEx.Request do
HTTPoison.put(endpoint, body, headers, Config.timeouts())
end
+
+ defp send(:delete, endpoint, _data) do
+ headers = [Authorization: "Bearer #{TokenHosting.get_token()}"]
+
+ HTTPoison.delete(endpoint, headers, Config.timeouts())
+ end
end