Skip to content

Commit

Permalink
Merge pull request #39 from vantage-sh/andy/report-alerts
Browse files Browse the repository at this point in the history
Report Alert resource and data source
  • Loading branch information
whereandy authored Apr 8, 2024
2 parents d0b22b1 + 6216e56 commit 1ec2c71
Show file tree
Hide file tree
Showing 10 changed files with 1,208 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ generate:
@echo "Generating Terraform code from OpenAPI spec"
tfplugingen-framework generate resources --input spec.json --output vantage
tfplugingen-framework generate data-sources --input spec.json --output vantage
rm tmp.json
rm spec.json tmp.json
5 changes: 5 additions & 0 deletions examples/data_sources/report_alerts.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "vantage_report_alerts" "all" {}

output "all_report_alerts" {
value = data.vantage_report_alerts.all
}
5 changes: 5 additions & 0 deletions examples/resources/vantage_report_alert/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "vantage_report_alert" "demo_report_alert" {
cost_report_token = "rpt_47c3254c790e9351"
threshold = 10
recipient_channels = ["#alerts"]
}
31 changes: 31 additions & 0 deletions generator.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
provider:
name: vantage

resources:
report_alert:
create:
path: /report_alerts
method: POST
read:
path: /report_alerts/{report_alert_token}
method: GET
update:
path: /report_alerts/{report_alert_token}
method: PUT
delete:
path: /report_alerts/{report_alert_token}
method: DELETE
schema:
attributes:
overrides:
token:
description: The token of the report alert
aliases:
report_alert_token: token

data_sources:
report_notifications:
read:
Expand Down Expand Up @@ -29,3 +51,12 @@ data_sources:
- limit
- links
- page
report_alerts:
read:
path: /report_alerts
method: GET
schema:
ignores:
- limit
- links
- page
9 changes: 9 additions & 0 deletions vantage/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vantage

import (
"context"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -120,3 +121,11 @@ func fromStringsValue(s []types.String) []string {

return out
}

func stringListFrom(in []string) (types.List, diag.Diagnostics) {
values := make([]types.String, 0, len(in))
for _, v := range in {
values = append(values, types.StringValue(v))
}
return types.ListValueFrom(context.Background(), types.StringType, values)
}
Loading

0 comments on commit 1ec2c71

Please sign in to comment.