|
4 | 4 | "context" |
5 | 5 | "errors" |
6 | 6 | "fmt" |
| 7 | + "maps" |
| 8 | + "slices" |
7 | 9 | "strconv" |
8 | 10 | "strings" |
9 | 11 |
|
@@ -341,6 +343,12 @@ var ( |
341 | 343 | Optional: true, |
342 | 344 | Elem: syntheticMonitoringCheckSettingsHTTPHeaderMatch, |
343 | 345 | }, |
| 346 | + "compression": { |
| 347 | + Description: "Check fails if the response body is not compressed using this compression algorithm. One of `none`, `identity`, `br`, `gzip`, `deflate`.", |
| 348 | + Type: schema.TypeString, |
| 349 | + Optional: true, |
| 350 | + ValidateFunc: validation.StringInSlice(slices.Collect(maps.Keys(sm.CompressionAlgorithm_value)), false), |
| 351 | + }, |
344 | 352 | "cache_busting_query_param_name": { |
345 | 353 | Description: "The name of the query parameter used to prevent the server from using a cached response. Each probe will assign a random value to this parameter each time a request is made.", |
346 | 354 | Type: schema.TypeString, |
@@ -936,6 +944,12 @@ func resourceCheckRead(ctx context.Context, d *schema.ResourceData, c *smapi.Cli |
936 | 944 | }, |
937 | 945 | ) |
938 | 946 | } |
| 947 | + // The default compression "none" is the same as omitting the value. |
| 948 | + // Since this value is usually not explicitly set, omit when set to "none" |
| 949 | + var compression string |
| 950 | + if chk.Settings.Http.Compression != sm.CompressionAlgorithm_none { |
| 951 | + compression = chk.Settings.Http.Compression.String() |
| 952 | + } |
939 | 953 | headerMatch := func(hms []sm.HeaderMatch) *schema.Set { |
940 | 954 | hmSet := schema.NewSet( |
941 | 955 | schema.HashResource(syntheticMonitoringCheckSettingsTCPQueryResponse), |
@@ -969,6 +983,7 @@ func resourceCheckRead(ctx context.Context, d *schema.ResourceData, c *smapi.Cli |
969 | 983 | "fail_if_body_not_matches_regexp": common.StringSliceToSet(chk.Settings.Http.FailIfBodyNotMatchesRegexp), |
970 | 984 | "fail_if_header_matches_regexp": headerMatch(chk.Settings.Http.FailIfHeaderMatchesRegexp), |
971 | 985 | "fail_if_header_not_matches_regexp": headerMatch(chk.Settings.Http.FailIfHeaderNotMatchesRegexp), |
| 986 | + "compression": compression, |
972 | 987 | "cache_busting_query_param_name": chk.Settings.Http.CacheBustingQueryParamName, |
973 | 988 | }) |
974 | 989 |
|
@@ -1475,6 +1490,10 @@ func makeCheckSettings(settings map[string]interface{}) (sm.CheckSettings, error |
1475 | 1490 | FailIfBodyNotMatchesRegexp: common.SetToStringSlice(h["fail_if_body_not_matches_regexp"].(*schema.Set)), |
1476 | 1491 | CacheBustingQueryParamName: h["cache_busting_query_param_name"].(string), |
1477 | 1492 | } |
| 1493 | + compression, ok := h["compression"].(string) |
| 1494 | + if ok { |
| 1495 | + cs.Http.Compression = sm.CompressionAlgorithm(sm.CompressionAlgorithm_value[compression]) |
| 1496 | + } |
1478 | 1497 | if h["tls_config"].(*schema.Set).Len() > 0 { |
1479 | 1498 | cs.Http.TlsConfig = tlsConfig(h["tls_config"].(*schema.Set)) |
1480 | 1499 | } |
|
0 commit comments