Skip to content

Commit

Permalink
add argument transaction_rate_limit on fortiadc_loadbalance_virtual_s…
Browse files Browse the repository at this point in the history
…erver resource (#54)
  • Loading branch information
pablo-ruth authored Mar 8, 2022
1 parent 865fb0d commit d9233fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/loadbalance_virtual_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ resource "fortiadc_loadbalance_virtual_server" "myvirtualserver" {
* `error_msg` - (Optional) Error message on backend failure.
* `error_page` - (Optional) Error page on backend failure.
* `persistence` - (Optional) Persistence configuration.
* `transaction_rate_limit` - (Optional) Limit of transactions per second. Defaults to `0`.

## Attribute Reference

Expand Down
13 changes: 13 additions & 0 deletions fortiadc/resource_fortiadc_loadbalance_virtual_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ func resourceFortiadcLoadbalanceVirtualServer() *schema.Resource {
Optional: true,
Default: false,
},
"transaction_rate_limit": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
},
}
}
Expand Down Expand Up @@ -221,6 +226,7 @@ func resourceFortiadcLoadbalanceVirtualServerCreate(d *schema.ResourceData, m in
ErrorMsg: d.Get("error_msg").(string),
ErrorPage: d.Get("error_page").(string),
TrafficLog: boolToEnable(d.Get("traffic_log").(bool)),
TransRateLimit: fmt.Sprintf("%d", d.Get("transaction_rate_limit").(int)),
}

err := client.LoadbalanceCreateVirtualServer(req)
Expand Down Expand Up @@ -307,6 +313,12 @@ func resourceFortiadcLoadbalanceVirtualServerRead(d *schema.ResourceData, m inte
}
arguments["connection_limit"] = connectionLimit

transactionRateLimit, err := strconv.ParseInt(rs.TransRateLimit, 10, 64)
if err != nil {
return err
}
arguments["transaction_rate_limit"] = transactionRateLimit

connectionRateLimit, err := strconv.ParseInt(rs.ConnectionRateLimit, 10, 64)
if err != nil {
return err
Expand Down Expand Up @@ -399,6 +411,7 @@ func resourceFortiadcLoadbalanceVirtualServerUpdate(d *schema.ResourceData, m in
ErrorMsg: d.Get("error_msg").(string),
ErrorPage: d.Get("error_page").(string),
TrafficLog: boolToEnable(d.Get("traffic_log").(bool)),
TransRateLimit: fmt.Sprintf("%d", d.Get("transaction_rate_limit").(int)),
}

err := client.LoadbalanceUpdateVirtualServer(req)
Expand Down

0 comments on commit d9233fd

Please sign in to comment.