summaryrefslogtreecommitdiff
path: root/lib/azure_ex
diff options
context:
space:
mode:
authorHentioe <me@bluerain.io>2020-10-29 10:48:53 +0800
committerHentioe <me@bluerain.io>2020-10-29 10:48:53 +0800
commitd3407fae886662947c75cc38421a32a75ff8da88 (patch)
tree94e65cd487a509e7dba0719047884d14d636420c /lib/azure_ex
parentAdd some APIs (diff)
Add some APIs to create resources
Diffstat (limited to 'lib/azure_ex')
-rw-r--r--lib/azure_ex/model/network_interfaces/create_or_update.ex41
-rw-r--r--lib/azure_ex/model/virtual_machines/create_or_update.ex64
-rw-r--r--lib/azure_ex/request.ex4
3 files changed, 107 insertions, 2 deletions
diff --git a/lib/azure_ex/model/network_interfaces/create_or_update.ex b/lib/azure_ex/model/network_interfaces/create_or_update.ex
new file mode 100644
index 0000000..bff597c
--- /dev/null
+++ b/lib/azure_ex/model/network_interfaces/create_or_update.ex
@@ -0,0 +1,41 @@
+defmodule AzureEx.Model.NetworkInterfaces.CreateOrUpdate do
+ @moduledoc false
+
+ use TypedStruct
+
+ alias __MODULE__.{Properties}
+
+ typedstruct module: Subnet do
+ @derive Jason.Encoder
+
+ field :id, String.t()
+ end
+
+ typedstruct module: NetworkInterfaceIPConfiguration.Properties do
+ @derive Jason.Encoder
+
+ field :subnet, Subnet.t()
+ end
+
+ typedstruct module: NetworkInterfaceIPConfiguration do
+ @derive Jason.Encoder
+
+ field :name, String.t()
+ field :properties, NetworkInterfaceIPConfiguration.Properties.t()
+ end
+
+ typedstruct module: Properties do
+ @derive Jason.Encoder
+
+ field :ipConfigurations, [NetworkInterfaceIPConfiguration.t()]
+ end
+
+ typedstruct do
+ @derive Jason.Encoder
+
+ field :id, String.t()
+
+ field :location, String.t()
+ field :properties, Properties.t(), default: %Properties{}
+ end
+end
diff --git a/lib/azure_ex/model/virtual_machines/create_or_update.ex b/lib/azure_ex/model/virtual_machines/create_or_update.ex
new file mode 100644
index 0000000..e719c0d
--- /dev/null
+++ b/lib/azure_ex/model/virtual_machines/create_or_update.ex
@@ -0,0 +1,64 @@
+defmodule AzureEx.Model.VirtualMachines.CreateOrUpdate do
+ @moduledoc false
+
+ use TypedStruct
+
+ alias __MODULE__.{Properties, NetworkInterfaceReference, StorageProfile}
+
+ typedstruct module: HardwareProfile do
+ @derive Jason.Encoder
+
+ field :vmSize, String.t()
+ end
+
+ typedstruct module: ImageReference do
+ @derive Jason.Encoder
+
+ field :offer, String.t()
+ field :publisher, String.t()
+ field :sku, String.t()
+ field :version, String.t()
+ end
+
+ typedstruct module: StorageProfile do
+ @derive Jason.Encoder
+
+ field :imageReference, ImageReference.t()
+ end
+
+ typedstruct module: NetworkInterfaceReference do
+ @derive Jason.Encoder
+
+ field :id, String.t()
+ end
+
+ typedstruct module: NetworkProfile do
+ @derive Jason.Encoder
+
+ field :networkInterfaces, [NetworkInterfaceReference.t()]
+ end
+
+ typedstruct module: OSProfile do
+ @derive Jason.Encoder
+
+ field :adminPassword, String.t()
+ field :adminUsername, String.t()
+ field :computerName, String.t()
+ end
+
+ typedstruct module: Properties do
+ @derive Jason.Encoder
+
+ field :hardwareProfile, HardwareProfile.t()
+ field :networkProfile, NetworkProfile.t()
+ field :storageProfile, StorageProfile.t()
+ field :osProfile, OSProfile.t()
+ end
+
+ typedstruct do
+ @derive Jason.Encoder
+
+ field :location, String.t()
+ field :properties, Properties.t(), default: %Properties{}
+ end
+end
diff --git a/lib/azure_ex/request.ex b/lib/azure_ex/request.ex
index c33cd51..88763f3 100644
--- a/lib/azure_ex/request.ex
+++ b/lib/azure_ex/request.ex
@@ -12,8 +12,8 @@ defmodule AzureEx.Request do
@type httpoison_result :: {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()}
@spec call(binary, method, data) :: {:ok, result} | {:error, error}
- def call(endpoint, method, body \\ %{}) do
- method |> send(endpoint, body) |> handle_response()
+ def call(endpoint, method, data \\ %{}) do
+ method |> send(endpoint, data) |> handle_response()
end
@spec handle_response({:ok, HTTPoison.Response.t()}) :: {:ok, result} | {:error, error}