diff --git a/synthetics/provider.go b/synthetics/provider.go index 6e4645d..4483911 100644 --- a/synthetics/provider.go +++ b/synthetics/provider.go @@ -17,6 +17,7 @@ package synthetics import ( "context" "regexp" + "strings" sc2 "github.com/splunk/syntheticsclient/v2/syntheticsclientv2" @@ -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..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(), @@ -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)