Skip to content

Commit

Permalink
Merge pull request #208 from ponkuma123/EUM_TERRAFORM_PROVIDER_BRANCH
Browse files Browse the repository at this point in the history
Supported credential profile for web page speed monitor
  • Loading branch information
jim-billy-zoho authored Nov 2, 2023
2 parents b9723db + 76cb513 commit 406b008
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ A terraform provider for managing the following resources in Site24x7:
- User - [site24x7_user](examples/user_us.tf) ([Site24x7 User API doc](https://www.site24x7.com/help/api/#users))
- Tag - [site24x7_tag](examples/tag_us.tf) ([Site24x7 Tag API doc](https://www.site24x7.com/help/api/#tags))
- Schedule Maintenance - [site24x7_schedule_maintenance](examples/schedule_maintenance_us.tf) ([Site24x7 Schedule Maintenance API doc](https://www.site24x7.com/help/api/#schedule-maintenances))
- Credential Profile - [site24x7_credential_profile](examples/credential_profiles_us.tf) ([Credential Profile Terraform doc](https://www.site24x7.com/help/api/#credential-profiles))
- Credential Profile - [site24x7_credential_profile](examples/credential_profiles_us.tf) ([Credential Profile API doc](https://www.site24x7.com/help/api/#credential-profiles))

#### Integrations

Expand Down
4 changes: 2 additions & 2 deletions api/endpoints/threshold_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *thresholdProfiles) Create(profile *api.ThresholdProfile) (*api.Threshol
err := c.client.
Post().
Resource("threshold_profiles").
SetHeader("Accept", "application/json;"). // We are overwriting the default API version 2.1 for HeartBeat monitor threshold profile addition to work.
SetHeader("Accept", "application/json; version=2.1"). // We are overwriting the default API version 2.1 for HeartBeat monitor threshold profile addition to work.
AddHeader("Content-Type", "application/json;charset=UTF-8").
Body(profile).
Do().
Expand All @@ -56,7 +56,7 @@ func (c *thresholdProfiles) Update(profile *api.ThresholdProfile) (*api.Threshol
Put().
Resource("threshold_profiles").
ResourceID(profile.ProfileID).
SetHeader("Accept", "application/json;"). // We are overwriting the default API version 2.1 for HeartBeat monitor threshold profile addition to work.
SetHeader("Accept", "application/json; version=2.1"). // We are overwriting the default API version 2.1 for HeartBeat monitor threshold profile addition to work.
AddHeader("Content-Type", "application/json;charset=UTF-8").
Body(profile).
Do().
Expand Down
13 changes: 7 additions & 6 deletions api/monitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ type WebPageSpeedMonitor struct {
DeviceType string `json:"device_type"`
WPAResolution string `json:"wpa_resolution"`
// HTTP Configuration
HTTPMethod string `json:"http_method"`
CustomHeaders []Header `json:"custom_headers,omitempty"`
AuthUser string `json:"auth_user,omitempty"`
AuthPass string `json:"auth_pass,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
UpStatusCodes string `json:"up_status_codes,omitempty"`
HTTPMethod string `json:"http_method"`
CustomHeaders []Header `json:"custom_headers,omitempty"`
AuthUser string `json:"auth_user,omitempty"`
AuthPass string `json:"auth_pass,omitempty"`
CredentialProfileID string `json:"credential_profile_id,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
UpStatusCodes string `json:"up_status_codes,omitempty"`
// Content Check
MatchingKeyword *ValueAndSeverity `json:"matching_keyword,omitempty"`
UnmatchingKeyword *ValueAndSeverity `json:"unmatching_keyword,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ type ThresholdProfile struct {
DownLocationThreshold int `json:"down_location_threshold,omitempty"`
WebsiteContentModified bool `json:"website_content_modified,omitempty"`
WebsiteContentChanges []map[string]interface{} `json:"website_content_changes,omitempty"`
ReadTimeOut map[string]interface{} `json:"read_time_out,omitempty"`
ResponseTimeThreshold map[string]interface{} `json:"response_time_threshold,omitempty"`
// SSL_CERT attributes
SSLCertificateFingerprintModified map[string]interface{} `json:"ssl_fingerprint_modified,omitempty"`
Expand Down Expand Up @@ -249,6 +250,8 @@ func (thresholdProfile *ThresholdProfile) UnmarshalJSON(rawValue []byte) error {
}
} else if k == "response_time_threshold" {
thresholdProfile.ResponseTimeThreshold = v.(map[string]interface{})
} else if k == "read_time_out" {
thresholdProfile.ReadTimeOut = v.(map[string]interface{})
}
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions docs/resources/rest_api_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ resource "site24x7_rest_api_monitor" "rest_api_monitor_us" {
}
// HTTP Configuration
//(Optional) Credential Profile to associate the website with
credential_profile_id = "123"
// (Optional) Provide a comma-separated list of HTTP status codes that indicate a successful response.
// You can specify individual status codes, as well as ranges separated with a colon.
up_status_codes = "400:500"
Expand Down Expand Up @@ -195,6 +199,7 @@ resource "site24x7_rest_api_monitor" "rest_api_monitor_us" {
* `client_certificate_password` (String) Password of the uploaded client certificate.
* `auth_pass` (String) Authentication user name to access the website.
* `auth_user` (String) Authentication password to access the website.
* `credential_profile_id` (String)Credential Profile to associate the website with. Notes: If you're using Auth user and Auth password, you can't configure Credential Profile
* `oauth2_provider` (String) Provider ID of the OAuth Provider to be associated with the monitor.
* `jwt_id` (String) Token ID of the Web Token to be associated with the monitor.
* `up_status_codes` (String) Provide a comma-separated list of HTTP status codes that indicate a successful response. You can specify individual status codes, as well as ranges separated with a colon.
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/rest_api_transaction_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ resource "site24x7_rest_api_transaction_monitor" "rest_api_transaction_monitor_e
}
// HTTP Configuration
//(Optional) Credential Profile to associate the website with
credential_profile_id = "123"
// (Optional) Provide a comma-separated list of HTTP status codes that indicate a successful response.
// You can specify individual status codes, as well as ranges separated with a colon.
up_status_codes = "400:500"
Expand Down Expand Up @@ -221,6 +224,7 @@ resource "site24x7_rest_api_transaction_monitor" "rest_api_transaction_monitor_e
* `auth_pass` (String) Authentication user name to access the website.
* `auth_user` (String) Authentication password to access the website.
* `auth_method` (String) Authentication method to access the website. Default value is 'B'. 'B' denotes Basic/NTLM. 'O' denotes OAuth 2 and 'W' denotes Web Token
* `credential_profile_id` (String)Credential Profile to associate the website with. Notes: If you're using Auth user and Auth password, you can't configure Credential Profile
* `oauth2_provider` (String) Provider ID of the OAuth Provider to be associated with the monitor. Default value for auth_method is "O".
* `jwt_id` (String) Token ID of the Web Token to be associated with the monitor.
* `up_status_codes` (String) Provide a comma-separated list of HTTP status codes that indicate a successful response. You can specify individual status codes, as well as ranges separated with a colon.
Expand Down
8 changes: 7 additions & 1 deletion docs/resources/threshold_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ resource "site24x7_threshold_profile" "website_threshold_profile_us" {
severity = 3
value = 95
}
// (Optional) Triggers alert when not receiving the website entire HTTP response within 30 seconds.
read_time_out {
severity = 3
value =true
}
// (Optional) Response time threshold configuration
primary_response_time_trouble_threshold = {
// https://www.site24x7.com/help/api/#threshold_severity
Expand Down Expand Up @@ -153,6 +158,7 @@ resource "site24x7_threshold_profile" "heartbeat_threshold" {
* `down_location_threshold` (Number) Triggers alert when the monitor is down from configured number of locations. Default value is '3'
* `profile_type` (Number) Static Threshold(1) or AI-based Threshold(2)
* `website_content_changes` (Block List) Triggers alert when Website content changes by configured percentage. (see [below for nested schema](#nestedblock--website_content_changes))
* `read_time_out` (Map of String) Triggers alert when not receiving the website entire HTTP response within 30 seconds. (see [below for nested schema](#nestedblock--website_content_changes))
* `website_content_modified` (Boolean) Triggers alert when the website content is modified.
* `primary_response_time_trouble_threshold` (Map of Number) Response time trouble threshold for the primary monitoring location. (see [below for map schema](#nestedblock--response_time_threshold))
* `primary_response_time_critical_threshold` (Map of Number) Response time critical threshold for the primary monitoring location. (see [below for map schema](#nestedblock--response_time_threshold))
Expand All @@ -168,7 +174,7 @@ ed.


<a id="nestedblock--website_content_changes"></a>
### Nested Schema for `website_content_changes`, `ssl_cert_days_until_expiry_trouble_threshold`, `ssl_cert_days_until_expiry_critical_threshold`
### Nested Schema for `website_content_changes`,`read_time_out`, `ssl_cert_days_until_expiry_trouble_threshold`, `ssl_cert_days_until_expiry_critical_threshold`

### Required

Expand Down
4 changes: 4 additions & 0 deletions docs/resources/web_page_speed_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ resource "site24x7_web_page_speed_monitor" "web_page_speed_monitor_example" {
// (Optional) Authentication password to access the website.
auth_pass = "thepasswd"
//(Optional) Credential Profile to associate the website with
credential_profile_id = "123"
// (Optional) Map of custom HTTP headers to send.
custom_headers = {
"Accept" = "application/json"
Expand Down Expand Up @@ -221,6 +224,7 @@ resource "site24x7_web_page_speed_monitor" "web_page_speed_monitor_example" {
* `user_agent` (String) User Agent to be used while monitoring the website.
* `auth_pass` (String) Authentication password to access the website.
* `auth_user` (String) Authentication user name to access the website.
* `credential_profile_id` (String)Credential Profile to associate the website with. Notes: If you're using Auth user and Auth password, you can't configure Credential Profile
* `up_status_codes` (String) Provide a comma-separated list of HTTP status codes that indicate a successful response. You can specify individual status codes, as well as ranges separated with a colon.
* `matching_keyword_severity` (Number) Severity with which alert has to raised when the matching keyword is found in the website response.
* `matching_keyword_value` (String) Check for the keyword in the website response.
Expand Down
5 changes: 4 additions & 1 deletion docs/resources/website_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ resource "site24x7_website_monitor" "website_monitor" {
// (Optional) Authentication password to access the website.
auth_pass = "thepasswd"
//(Optional) Credential Profile to associate the website with
credential_profile_id = "123"
// (Optional) Check for the keyword in the website response.
matching_keyword_value = "foo"
Expand Down Expand Up @@ -224,7 +227,7 @@ resource "site24x7_website_monitor" "website_monitor" {
* `auth_method` (String) Authentication method to access the website. Default value is 'B'. 'B' denotes Basic/NTLM. 'O' denotes OAuth 2 and 'W' denotes Web Token.
* `auth_pass` (String) Authentication password to access the website.
* `auth_user` (String) Authentication user name to access the website.
* `credential_profile_id` (String) Credential Profile to associate.
* `credential_profile_id` (String)Credential Profile to associate the website with. Notes: If you're using Auth user and Auth password, you can't configure Credential Profile
* `client_certificate_password` (String) Password of the client certificate.
* `use_name_server` (Boolean) Resolve the IP address using Domain Name Server.
* `forced_ips` (String) Provide the domain name or IP addresses to be used for monitoring instead of using the IPs resolved from the given URL.
Expand Down
5 changes: 5 additions & 0 deletions examples/threshold_profile_us.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ resource "site24x7_threshold_profile" "website_threshold_profile_us" {
down_location_threshold = 1
// (Optional) Triggers alert when Website content is modified.
website_content_modified = false
// (Optional) Triggers alert when not receiving the website entire HTTP response within 30 seconds.
read_time_out {
severity = 3
value = true
}
// (Optional) Triggers alert when Website content changes by configured percentage.
website_content_changes {
severity = 2
Expand Down
19 changes: 13 additions & 6 deletions site24x7/monitors/web_page_speed.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ var webPageSpeedMonitorSchema = map[string]*schema.Schema{
Optional: true,
Description: "Authentication password to access the website.",
},
"credential_profile_id": {
Type: schema.TypeString,
Optional: true,
Description: "Credential Profile to associate.",
},
"user_agent": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -484,12 +489,13 @@ func resourceDataToWebPageSpeedMonitor(d *schema.ResourceData, client site24x7.C
DeviceType: d.Get("device_type").(string),
WPAResolution: d.Get("wpa_resolution").(string),
// HTTP Configuration
HTTPMethod: d.Get("http_method").(string),
CustomHeaders: customHeaders,
AuthUser: d.Get("auth_user").(string),
AuthPass: d.Get("auth_pass").(string),
UserAgent: d.Get("user_agent").(string),
UpStatusCodes: d.Get("up_status_codes").(string),
HTTPMethod: d.Get("http_method").(string),
CustomHeaders: customHeaders,
AuthUser: d.Get("auth_user").(string),
AuthPass: d.Get("auth_pass").(string),
CredentialProfileID: d.Get("credential_profile_id").(string),
UserAgent: d.Get("user_agent").(string),
UpStatusCodes: d.Get("up_status_codes").(string),
// Content Check
MatchCase: d.Get("match_case").(bool),
LocationProfileID: d.Get("location_profile_id").(string),
Expand Down Expand Up @@ -584,6 +590,7 @@ func updateWebPageSpeedMonitorResourceData(d *schema.ResourceData, monitor *api.
d.Set("custom_headers", customHeaders)
d.Set("auth_user", monitor.AuthUser)
d.Set("auth_pass", monitor.AuthPass)
d.Set("credential_profile_id", monitor.CredentialProfileID)
d.Set("user_agent", monitor.UserAgent)
d.Set("up_status_codes", monitor.UpStatusCodes)

Expand Down
30 changes: 30 additions & 0 deletions site24x7/threshold_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ var ThresholdProfileSchema = map[string]*schema.Schema{
ValidateFunc: validation.IntInSlice([]int{1, 2}),
Description: "Static Threshold(1) or AI-based Threshold(2)",
},
"profile_type_name": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validation.IntInSlice([]int{1, 2}),
Description: "Static Threshold(1) or AI-based Threshold(2)",
},
"down_location_threshold": {
Type: schema.TypeInt,
Optional: true,
Expand All @@ -98,6 +105,24 @@ var ThresholdProfileSchema = map[string]*schema.Schema{
Optional: true,
Description: "Triggers alert when the website content is modified.",
},
"read_time_out": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"severity": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntInSlice([]int{0, 2, 3}), //Down or Trouble or Critical
},
"value": {
Type: schema.TypeBool,
Required: true,
},
},
},
Description: "Triggers alert when not receiving the website entire HTTP response within 30 seconds.",
},
"website_content_changes": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -550,6 +575,10 @@ func setCommonAttributes(d *schema.ResourceData, thresholdProfile *api.Threshold
}
thresholdProfile.WebsiteContentChanges = websiteContentChanges

if readTimeOut, ok := d.GetOk("read_time_out"); ok {
thresholdProfile.ReadTimeOut = readTimeOut.(map[string]interface{})
}

// Response Time Threshold
var setResponseTimeThresholdMap bool
responseTimeThresholdMap := make(map[string]interface{})
Expand Down Expand Up @@ -594,6 +623,7 @@ func setCommonResourceData(d *schema.ResourceData, thresholdProfile *api.Thresho
d.Set("down_location_threshold", thresholdProfile.DownLocationThreshold)
d.Set("website_content_modified", thresholdProfile.WebsiteContentModified)
d.Set("website_content_changes", thresholdProfile.WebsiteContentChanges)
d.Set("read_time_out", thresholdProfile.ReadTimeOut)
// Response Time Primary Threshold
if primaryThreshold, ok := thresholdProfile.ResponseTimeThreshold["primary"]; ok {
primaryThresholdList := primaryThreshold.([]interface{})
Expand Down

0 comments on commit 406b008

Please sign in to comment.