Skip to content

Commit 410cb0e

Browse files
Merge pull request #27 from statuspal/add-metric-data-source
feat: add metric and metrics data source
2 parents 63bcd79 + 66f7d2e commit 410cb0e

File tree

17 files changed

+721
-95
lines changed

17 files changed

+721
-95
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes of the StatusPal Terraform provider will be documented in th
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.0] - 2024-10-17
9+
10+
### Added
11+
12+
- Metric resource and metrics data source.
13+
814
## [0.2.12] - 2024-10-17
915

1016
### Fixed

docs/data-sources/metrics.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "statuspal_metrics Data Source - statuspal"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# statuspal_metrics (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
# List all metrics of the status page with subdomain "example-com".
17+
data "statuspal_metrics" "example" {
18+
status_page_subdomain = "example-com"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `status_page_subdomain` (String) The status page subdomain of the services.
28+
29+
### Optional
30+
31+
- `query` (Block, Optional) (see [below for nested schema](#nestedblock--query))
32+
33+
### Read-Only
34+
35+
- `id` (String) Placeholder identifier attribute. Ignore it, only used in testing.
36+
- `metrics` (Attributes List) The metrics (see [below for nested schema](#nestedatt--metrics))
37+
38+
<a id="nestedblock--query"></a>
39+
### Nested Schema for `query`
40+
41+
Optional:
42+
43+
- `after` (String) Used as a cursor for pagination
44+
- `before` (String) Used as a cursor for pagination
45+
- `limit` (Number) Set the number of metrics to return in the response. This defaults to 20 items
46+
47+
48+
<a id="nestedatt--metrics"></a>
49+
### Nested Schema for `metrics`
50+
51+
Required:
52+
53+
- `id` (String) The unique identifier for the metric.
54+
55+
Read-Only:
56+
57+
- `enabled` (Boolean) A flag indicating if the metric is enabled.
58+
- `featured_number` (String) A featured number for the metric.
59+
- `integration_id` (Number) The integration ID related to the metric.
60+
- `latest_entry_time` (Number) The timestamp for the latest entry of the metric.
61+
- `order` (Number) The order of the metric in the system.
62+
- `remote_id` (String) The remote ID for the metric.
63+
- `remote_name` (String) The remote name for the metric.
64+
- `status` (String) The status of the metric.
65+
- `threshold` (Number) The threshold value for the metric.
66+
- `title` (String) The title of the metric.
67+
- `type` (String) The type of the metric.
68+
- `unit` (String) The unit of measurement for the metric.
69+
- `visible` (Boolean) A flag indicating if the metric is visible.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ terraform {
1818
required_providers {
1919
statuspal = {
2020
source = "statuspal/statuspal"
21-
version = "0.2.12"
21+
version = "0.3.0"
2222
}
2323
}
2424

docs/resources/metric.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "statuspal_metric Resource - statuspal"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# statuspal_metric (Resource)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Manage example metric of the status page with subdomain "example-com".
17+
resource "statuspal_metric" "example" {
18+
status_page_subdomain = "example-com"
19+
metric = {
20+
title = "example"
21+
unit = "ms"
22+
type = "rt"
23+
}
24+
}
25+
```
26+
27+
<!-- schema generated by tfplugindocs -->
28+
## Schema
29+
30+
### Required
31+
32+
- `metric` (Attributes) The metric. (see [below for nested schema](#nestedatt--metric))
33+
- `status_page_subdomain` (String) The status page subdomain of the services.
34+
35+
### Read-Only
36+
37+
- `id` (String) Placeholder identifier attribute. Ignore it, only used in testing.
38+
39+
<a id="nestedatt--metric"></a>
40+
### Nested Schema for `metric`
41+
42+
Required:
43+
44+
- `title` (String) The title of the metric.
45+
- `type` (String) The type of the metric.
46+
- `unit` (String) The unit of measurement for the metric.
47+
48+
Optional:
49+
50+
- `enabled` (Boolean) A flag indicating if the metric is enabled.
51+
- `featured_number` (String) A featured number for the metric.
52+
- `integration_id` (Number) The integration ID related to the metric.
53+
- `order` (Number) The order of the metric in the system.
54+
- `remote_id` (String) The remote ID for the metric.
55+
- `remote_name` (String) The remote name for the metric.
56+
- `threshold` (Number) The threshold value for the metric.
57+
- `visible` (Boolean) A flag indicating if the metric is visible.
58+
59+
Read-Only:
60+
61+
- `id` (String) The unique identifier for the metric.
62+
- `latest_entry_time` (Number) The timestamp for the latest entry of the metric.
63+
- `status` (String) The status of the metric.
64+
65+
## Import
66+
67+
Import is supported using the following syntax:
68+
69+
```shell
70+
# Service can be imported by specifying the status page subdomain and metric ID.
71+
terraform import statuspal_metric.example "example-com 1"
72+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# List all metrics of the status page with subdomain "example-com".
2+
data "statuspal_metrics" "example" {
3+
status_page_subdomain = "example-com"
4+
}

examples/metric/main.tf

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ provider "statuspal" {
1313
region = "US"
1414
}
1515

16-
resource "statuspal_status_page" "example" {
17-
organization_id = "1"
18-
status_page = {
19-
name = "example"
20-
url = "example.com"
21-
time_zone = "Europe/Berlin"
22-
}
23-
}
24-
25-
resource "statuspal_metric" "example" {
26-
status_page_subdomain = statuspal_status_page.example.status_page.subdomain
16+
resource "statuspal_metric" "edu" {
17+
status_page_subdomain = "example-com"
2718
metric = {
2819
title = "example"
2920
unit = "ms"
3021
type = "rt"
3122
}
3223
}
24+
25+
output "example_statuspal_metric" {
26+
value = statuspal_metric.edu
27+
}

examples/metrics/main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
terraform {
2+
required_providers {
3+
statuspal = {
4+
source = "registry.terraform.io/statuspal/statuspal"
5+
}
6+
}
7+
8+
required_version = ">= 1.2.0"
9+
}
10+
11+
provider "statuspal" {
12+
api_key = "uk_aERPQU1kUzUrRmplaXJRMlc2TDEwZz09"
13+
region = "US" // "US" or "EU"
14+
}
15+
16+
data "statuspal_metrics" "edu" {
17+
status_page_subdomain = "example-com"
18+
}
19+
20+
21+
output "edu_statuspal_metrics" {
22+
value = data.statuspal_metrics.edu
23+
}

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
statuspal = {
55
source = "statuspal/statuspal"
6-
version = "0.2.12"
6+
version = "0.3.0"
77
}
88
}
99

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Service can be imported by specifying the status page subdomain and metric ID.
2+
terraform import statuspal_metric.example "example-com 1"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Manage example metric of the status page with subdomain "example-com".
2+
resource "statuspal_metric" "example" {
3+
status_page_subdomain = "example-com"
4+
metric = {
5+
title = "example"
6+
unit = "ms"
7+
type = "rt"
8+
}
9+
}

0 commit comments

Comments
 (0)