Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions synthetics/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package synthetics
import (
"context"
"regexp"
"strings"

sc2 "github.com/splunk/syntheticsclient/v2/syntheticsclientv2"

Expand Down Expand Up @@ -48,6 +49,12 @@ func Provider() *schema.Provider {
Description: "Splunk Observability Realm (E.G. `us1`). Will pull from `REALM` environment variable if available. For Rigor use realm rigor",
DefaultFunc: schema.EnvDefaultFunc("REALM", nil),
},
"apiUrl": {
Type: schema.TypeString,
Optional: true,
Description: "Splunk Observability Realm API Endpoint (E.G. `https://api.<REALM>.signalfx.com`). Will pull from `API_URL` environment variable if available.",
DefaultFunc: schema.EnvDefaultFunc("API_URL", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"synthetics_create_http_check": resourceHttpCheck(),
Expand Down Expand Up @@ -82,14 +89,26 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
token := d.Get("apikey").(string)
realm := d.Get("realm").(string)
product := d.Get("product").(string)
apiUrl := d.Get("apiUrl").(string)

var diags diag.Diagnostics

if product == "observability" {
if token != "" && realm != "" {
c := sc2.NewClient(token, realm)

return c, diags
if apiUrl != "" {
args := sc2.ClientArgs {
timeoutSeconds: 30,
publicBaseUrl: strings.TrimSuffix(apiUrl, "/") + "/v2/synthetics"
}

c := sc2.NewConfigurableClient(token, realm, args)

return c, diags
} else {
c := sc2.NewClient(token, realm)

return c, diags
}
}

c := sc2.NewClient(token, realm)
Expand Down
Loading