Skip to content

Commit

Permalink
Add support for using some other Site24x7 data center instead of the …
Browse files Browse the repository at this point in the history
…default US one (#29)

* Support overriding API base URL and token endpoint

* Document API/Token URL overriding
  • Loading branch information
mpeltonen authored Apr 20, 2021
1 parent 9e7ef30 commit 186f475
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,14 @@ provider "site24x7" {
// The refresh token will be looked up in the SITE24X7_OAUTH2_REFRESH_TOKEN
// environment variable if the attribute is empty or omitted.
oauth2_refresh_token = "${var.oauth2_refresh_token}"
// Specify the following configuration options if you want to use
// some other Site24x7 data center than the default US one. These
// must correspond to the data center from which you have obtained your
// OAuth client credentials and refresh token.
// Use European data center for API and tokens
api_base_url = "https://www.site24x7.eu/api"
token_url = "https://accounts.zoho.eu/oauth/v2/token"
}
```
9 changes: 9 additions & 0 deletions _examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ provider "site24x7" {

// Maximum number of Site24x7 API request retries to perform until giving up.
max_retries = 4

// Site24x7 API base URL to use. Used to select the desired data center.
// See https://www.site24x7.com/help/api/#introduction
api_base_url = "https://www.site24x7.com/api"

// Site24x7 token URL to use. Used to select the desired data center.
// See https://www.site24x7.com/help/api/#authentication
// NOTE: This needs to be configured to match the API base URL domain.
token_url = "https://accounts.zoho.com/oauth/v2/token"
}

// IT Automation API doc: https://www.site24x7.com/help/api/#it-automation
Expand Down
11 changes: 11 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ provider "site24x7" {
// Maximum number of Site24x7 API request retries to perform until giving up.
max_retries = 4
// Site24x7 API base URL to use. Used to select the desired data center.
// See https://www.site24x7.com/help/api/#introduction
api_base_url = "https://www.site24x7.com/api"
// Site24x7 token URL to use. Used to select the desired data center.
// See https://www.site24x7.com/help/api/#authentication
// NOTE: This needs to be configured to match the API base URL domain.
token_url = "https://accounts.zoho.com/oauth/v2/token"
}
// IT Automation API doc: https://www.site24x7.com/help/api/#it-automation
Expand Down Expand Up @@ -222,6 +231,8 @@ resource "site24x7_website_monitor" "website_monitor" {

### Optional

- **api_base_url** (String) Site24x7 API base url to use.
- **max_retries** (Number) Maximum number of retries for Site24x7 API errors until giving up
- **retry_max_wait** (Number) Maximum wait time in seconds before retrying failed API requests (exponential backoff).
- **retry_min_wait** (Number) Minimum wait time in seconds before retrying failed API requests.
- **token_url** (String) Site24x7 OAuth token url to use.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Bonial-International-GmbH/terraform-provider-site24x7
go 1.12

require (
github.com/Bonial-International-GmbH/site24x7-go v0.0.5
github.com/Bonial-International-GmbH/site24x7-go v0.0.6
github.com/hashicorp/terraform-plugin-sdk v1.1.1
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/Bonial-International-GmbH/site24x7-go v0.0.4 h1:QBhopy/qCoqmuLFkCa6y3
github.com/Bonial-International-GmbH/site24x7-go v0.0.4/go.mod h1:t8PPOZgtwUCU9xodDhmt5ATqTHkIQgyzCkgjze7zz90=
github.com/Bonial-International-GmbH/site24x7-go v0.0.5 h1:9XRcZ/35UCiclcbyxoDEM9q+UZiVcSE5MQo2h72ccLY=
github.com/Bonial-International-GmbH/site24x7-go v0.0.5/go.mod h1:t8PPOZgtwUCU9xodDhmt5ATqTHkIQgyzCkgjze7zz90=
github.com/Bonial-International-GmbH/site24x7-go v0.0.6 h1:R4cP4M5aPHY+lGXvmjzdVK39o99Cy5i7Yg12v3Qbbuo=
github.com/Bonial-International-GmbH/site24x7-go v0.0.6/go.mod h1:t8PPOZgtwUCU9xodDhmt5ATqTHkIQgyzCkgjze7zz90=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
12 changes: 12 additions & 0 deletions site24x7/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ func Provider() terraform.ResourceProvider {
Default: 4,
Description: "Maximum number of retries for Site24x7 API errors until giving up",
},
"api_base_url": {
Type: schema.TypeString,
Optional: true,
Description: "Site24x7 API base url to use.",
},
"token_url": {
Type: schema.TypeString,
Optional: true,
Description: "Site24x7 OAuth token url to use.",
},
},

ResourcesMap: map[string]*schema.Resource{
Expand All @@ -72,6 +82,8 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
ClientID: d.Get("oauth2_client_id").(string),
ClientSecret: d.Get("oauth2_client_secret").(string),
RefreshToken: d.Get("oauth2_refresh_token").(string),
APIBaseURL: d.Get("api_base_url").(string),
TokenURL: d.Get("token_url").(string),
RetryConfig: &backoff.RetryConfig{
MinWait: time.Duration(d.Get("retry_min_wait").(int)) * time.Second,
MaxWait: time.Duration(d.Get("retry_max_wait").(int)) * time.Second,
Expand Down

0 comments on commit 186f475

Please sign in to comment.