Skip to content

Commit

Permalink
[andromeda] add domain_name and http_method arg to gslb monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Oct 22, 2024
1 parent b5a1203 commit 8f06132
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ccloud/resource_ccloud_gslb_monitor_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func resourceCCloudGSLBMonitorV1() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"domain_name": {
Type: schema.TypeString,
Optional: true,
},
"pool_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -76,6 +80,14 @@ func resourceCCloudGSLBMonitorV1() *schema.Resource {
Optional: true,
Default: "ICMP",
},
"http_method": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS",
}, false),
Optional: true,
Default: "GET",
},

// computed
"provisioning_status": {
Expand Down Expand Up @@ -113,6 +125,9 @@ func resourceCCloudGSLBMonitorV1Create(ctx context.Context, d *schema.ResourceDa
if v, ok := d.GetOk("name"); ok && v != "" {
monitor.Name = ptr(v.(string))
}
if v, ok := d.GetOk("domain_name"); ok && v != "" {
monitor.DomainName = ptr(strfmt.Hostname(v.(string)))
}
if v, ok := d.GetOk("pool_id"); ok && v != "" {
v := strfmt.UUID(v.(string))
monitor.PoolID = &v
Expand All @@ -132,6 +147,9 @@ func resourceCCloudGSLBMonitorV1Create(ctx context.Context, d *schema.ResourceDa
if v, ok := d.GetOk("type"); ok && v != "" {
monitor.Type = ptr(v.(string))
}
if v, ok := d.GetOk("http_method"); ok && v != "" {
monitor.HTTPMethod = ptr(v.(string))
}

opts := &monitors.PostMonitorsParams{
Monitor: monitors.PostMonitorsBody{
Expand Down Expand Up @@ -212,6 +230,10 @@ func resourceCCloudGSLBMonitorV1Update(ctx context.Context, d *schema.ResourceDa
v := d.Get("name").(string)
monitor.Name = &v
}
if d.HasChange("domain_name") {
v := strfmt.Hostname(d.Get("domain_name").(string))
monitor.DomainName = &v
}
if d.HasChange("pool_id") {
v := strfmt.UUID(d.Get("pool_id").(string))
monitor.PoolID = &v
Expand All @@ -232,6 +254,10 @@ func resourceCCloudGSLBMonitorV1Update(ctx context.Context, d *schema.ResourceDa
v := d.Get("type").(string)
monitor.Type = &v
}
if d.HasChange("http_method") {
v := d.Get("http_method").(string)
monitor.HTTPMethod = &v
}

opts := &monitors.PutMonitorsMonitorIDParams{
Monitor: monitors.PutMonitorsMonitorIDBody{
Expand Down Expand Up @@ -346,12 +372,14 @@ func andromedaSetMonitorResource(d *schema.ResourceData, config *Config, monitor
d.Set("admin_state_up", ptrValue(monitor.AdminStateUp))
d.Set("interval", ptrValue(monitor.Interval))
d.Set("name", ptrValue(monitor.Name))
d.Set("domain_name", ptrValue(monitor.DomainName))
d.Set("pool_id", ptrValue(monitor.PoolID))
d.Set("project_id", ptrValue(monitor.ProjectID))
d.Set("receive", ptrValue(monitor.Receive))
d.Set("send", ptrValue(monitor.Send))
d.Set("timeout", ptrValue(monitor.Timeout))
d.Set("type", ptrValue(monitor.Type))
d.Set("http_method", ptrValue(monitor.HTTPMethod))

// computed
d.Set("provisioning_status", monitor.ProvisioningStatus)
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/gslb_monitor_v1.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ The following arguments are supported:

* `name` - (Optional) The name of the monitor.

* `domain_name` - (Optional) The domain name to use in the HTTP host header.
Only used with `HTTP` and `HTTPS` monitor types.

* `pool_id` - (Optional) The ID of the pool that this monitor is associated
with.

Expand All @@ -62,6 +65,10 @@ The following arguments are supported:
check the health of the monitored resource. Supported types are `ICMP`,
`HTTP`, `HTTPS`, `TCP`, and `UDP`. Defaults to `ICMP`.

* `http_method` - (Optional) The HTTP method to use for the monitor. Supported
methods are `GET`, `POST`, `PUT`, `HEAD`, `DELETE` and `OPTIONS`. Only used
with `HTTP` and `HTTPS` monitor types. Defaults to `GET`.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:
Expand Down

0 comments on commit 8f06132

Please sign in to comment.