Skip to content

Commit

Permalink
Add default values and send empty array when list are not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
dianibar committed Dec 5, 2023
1 parent 05948d1 commit 52e946c
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 67 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
required_providers {
doit = {
source = "doitintl/doit"
version = "0.2.1"
version = "0.5.0"
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion docs/resources/attribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ description: |-




## Example Usage

```terraform
# Manage Attribution group
resource "doit_attribution" "attri" {
name = "attritestnewname9"
description = "attritestdiana8"
formula = "A"
components = [{ type = "label", key = "iris_location", values = ["us"] }]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
11 changes: 10 additions & 1 deletion docs/resources/attribution_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ description: |-




## Example Usage

```terraform
# Manage Attribution group
resource "doit_attribution_group" "attributeGroup" {
name = "attritestnewgroup"
description = "attritestgroup"
attributions = [doit_attribution.attribute1.id, doit_attribution.attribute2.id]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
72 changes: 65 additions & 7 deletions docs/resources/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,68 @@ description: |-




## Example Usage

```terraform
resource "doit_report" "my-report" {
name = "test_report"
description = "test_report"
config = {
metric = {
type = "basic"
value = "cost"
}
include_promotional_credits = false
advanced_analysis = {
trending_up = false
trending_down = false
not_trending = false
forecast = false
}
aggregation = "total"
time_interval = "month"
dimensions = [
{
id = "year"
type = "datetime"
},
{
id = "month"
type = "datetime"
}
]
time_range = {
mode = "last"
amount = 12
include_current = true
unit = "month"
}
filters = [
{
inverse = false
id = "attribution"
type = "attribution"
values = [
"1CE699ZdwN5CRBw0tInY"
]
}
]
group = [
{
id = "BSQZmvX6hvuKGPDHX7R3"
type = "attribution_group"
},
{
id = "cloud_provider"
type = "fixed"
}
]
layout = "table"
display_values = "actuals_only"
currency = "USD"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -32,19 +93,16 @@ description: |-
<a id="nestedatt--config"></a>
### Nested Schema for `config`

Required:

- `advanced_analysis` (Attributes) (see [below for nested schema](#nestedatt--config--advanced_analysis))
- `include_promotional_credits` (Boolean) Whether to include credits or not. If set, the report must use time interval “month”/”quarter”/”year”

Optional:

- `advanced_analysis` (Attributes) (see [below for nested schema](#nestedatt--config--advanced_analysis))
- `aggregation` (String)
- `currency` (String)
- `dimensions` (Attributes List) (see [below for nested schema](#nestedatt--config--dimensions))
- `display_values` (String)
- `filters` (Attributes List) The filters to use in this report (see [below for nested schema](#nestedatt--config--filters))
- `group` (Attributes List) The groups to use in the report. (see [below for nested schema](#nestedatt--config--group))
- `include_promotional_credits` (Boolean) Whether to include credits or not. If set, the report must use time interval “month”/”quarter”/”year”
- `layout` (String)
- `metric` (Attributes) (see [below for nested schema](#nestedatt--config--metric))
- `metric_filter` (Attributes) (see [below for nested schema](#nestedatt--config--metric_filter))
Expand All @@ -55,7 +113,7 @@ Optional:
<a id="nestedatt--config--advanced_analysis"></a>
### Nested Schema for `config.advanced_analysis`

Required:
Optional:

- `forecast` (Boolean) Advanced analysis toggles. Each of these can be set independently
- `not_trending` (Boolean)
Expand Down
14 changes: 12 additions & 2 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ terraform {
required_providers {
doit = {
source = "doitintl/doit"
version = "0.3.1"
version = "0.5.0"
}
}
}

resource "doit_report" "my-report" {
name = "test10"
name = "test_new_provider"
config = {
metric = {
type = "basic"
Expand Down Expand Up @@ -59,6 +59,16 @@ resource "doit_report" "my-report" {
type = "fixed"
}
]
group = [
{
id = "BSQZmvX6hvuKGPDHX7R3"
type = "attribution_group"
},
{
id = "cloud_provider"
type = "fixed"
}
]
layout = "table"
display_values = "actuals_only"
currency = "USD"
Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
doit = {
source = "doitintl/doit"
version = "0.2.1"
version = "0.5.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "doit_report" "my-report" {
name = "test10"
description = "test10"
name = "test_report"
description = "test_report"
config = {
metric = {
type = "basic"
Expand Down
3 changes: 0 additions & 3 deletions internal/provider/attribution_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ func (r *attributionResource) Configure(_ context.Context, req resource.Configur
// Create creates the resource and sets the initial Terraform state.
func (r *attributionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
log.Println(" attribution Create")
log.Println(r.client.Auth.DoiTAPITOken)
log.Println("---------------------------------------------------")
log.Println(r.client.Auth.CustomerContext)

// Retrieve values from plan
var plan attributionResourceModel
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ type ExternalConfig struct {
DisplayValues string `json:"displayValues,omitempty"`

// Filters The filters to use in this report
Filters []ExternalConfigFilter `json:"filters,omitempty"`
Filters []ExternalConfigFilter `json:"filters"`

// Group The groups to use in the report.
Group []Group `json:"group,omitempty"`
Group []Group `json:"group"`

// IncludePromotionalCredits Whether to include credits or not.
// If set, the report must use time interval “month”/”quarter”/”year”
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

// CreateReport - Create new report
func (c *ClientTest) CreateReport(report Report) (*Report, error) {
log.Println("CreateReport----------------")
log.Println(report.Config.Filters)
rb, err := json.Marshal(report)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 52e946c

Please sign in to comment.