diff --git a/synthetics/provider.go b/synthetics/provider.go index 6e4645d..9329798 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,28 +89,34 @@ 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) + if apiurl != "" { + args := sc2.NewClientArgs( + 30, + strings.TrimSuffix(apiurl, "/")+"/v2/synthetics", + ) + c := sc2.NewConfigurableClient(token, realm, args) + return c, diags + } + // Default client (no apiurl override) + c := sc2.NewClient(token, realm) return c, diags } c := sc2.NewClient(token, realm) - return c, diags } else { if product == "rigor" && token != "" { c := sc.NewClient(token) - return c, diags } - c := sc.NewClient(token) - return c, diags } } diff --git a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/synthetics.go b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/synthetics.go index 00f7e7d..57e8722 100644 --- a/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/synthetics.go +++ b/vendor/github.com/splunk/syntheticsclient/v2/syntheticsclientv2/synthetics.go @@ -121,6 +121,13 @@ func (c Client) makePublicAPICall(method string, endpoint string, requestBody io return &details, nil } +func NewClientArgs(timeout int, baseUrl string) ClientArgs { + return ClientArgs{ + timeoutSeconds: timeout, + publicBaseUrl: baseUrl, + } +} + func NewClient(apiKey string, realm string) *Client { args := ClientArgs{timeoutSeconds: 30} return NewConfigurableClient(apiKey, realm, args)