sdk "github.com/aziontech/azionapi-go-sdk/edgefirewall"
Name string `json:"name"`
// Define the firewall URL as a constant
firewallURL = "https://api.azionapi.net/"
// Client struct to hold the API client
// Request the user's personal token
fmt.Println("Hey, there! Welcome to Edge Firewall example")
fmt.Println("Please, provide your Personal Token: ")
fmt.Scanf("%s", &personalToken)
// Handle the firewall with the provided token
err := firewallHandler(personalToken)
// firewallHandler handles the firewall operations
func firewallHandler(personalToken string) error {
// Request the firewall name from the user
fmt.Println("Please, provide the Edge Firewall name: ")
reader := bufio.NewReader(os.Stdin)
firewallName, err := reader.ReadString('\n')
// Remove newline character from the firewall name
firewallName = strings.Replace(firewallName, "\n", "", -1)
// Create a new client and firewall
var httpClient *http.Client
client := NewClient(httpClient, firewallURL, personalToken)
err = client.NewFirewall(&firewallName)
// NewFirewall creates a new firewall
func (c *Client) NewFirewall(firewallName *string) error {
ctx := context.Background()
// Create a new firewall request
firewall := new(sdk.CreateEdgeFirewallRequest)
firewall.Name = firewallName
fmt.Println("\nCreating Edge Firewall....\n")
// Execute the firewall request
req := c.apiClient.DefaultAPI.EdgeFirewallPost(ctx).CreateEdgeFirewallRequest(*firewall)
_, httpResp, err := req.Execute()
// Read and print the response
bytes, err := io.ReadAll(httpResp.Body)
err = json.Unmarshal(bytes, &response)
fmt.Println("Edge Firewall succesfully created\n")
fmt.Println("Name: " + response.Results.Name)
fmt.Println("ID: " + strconv.Itoa(response.Results.ID) + "\n")
// NewClient creates a new client with the provided HTTP client, URL, and token
func NewClient(httpClient *http.Client, url string, token string) *Client {
// Create a new configuration
conf := sdk.NewConfiguration()
// Set the HTTP client and headers
conf.HTTPClient = httpClient
conf.AddDefaultHeader("Authorization", "token "+token)
conf.AddDefaultHeader("Accept", "application/json;version=3")
conf.Servers = sdk.ServerConfigurations{
// Return a new client with the configuration
apiClient: *sdk.NewAPIClient(conf),