Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions btp/provider/datasource_subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ You must be assigned to the admin or viewer role of the global account, director
getFormattedValueAsTableRow("`USED_FOR_PRODUCTION`", "The subaccount is used for production purposes."),
Computed: true,
},
"contract_status": schema.StringAttribute{
MarkdownDescription: "Shows the contract status of the subaccount.",
Computed: true,
},
},
}
}
Expand Down
4 changes: 3 additions & 1 deletion btp/provider/datasource_subaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestDataSourceSubaccount(t *testing.T) {
resource.TestCheckResourceAttr("data.btp_subaccount.test", "region", "eu12"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "state", "OK"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "usage", "NOT_USED_FOR_PRODUCTION"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "contract_status", "ACTIVE"),
),
},
},
Expand Down Expand Up @@ -65,6 +66,7 @@ func TestDataSourceSubaccount(t *testing.T) {
resource.TestCheckResourceAttr("data.btp_subaccount.test", "region", "eu12"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "state", "OK"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "usage", "NOT_USED_FOR_PRODUCTION"),
resource.TestCheckResourceAttr("data.btp_subaccount.test", "contract_status", "ACTIVE"),
),
},
},
Expand All @@ -81,7 +83,7 @@ func TestDataSourceSubaccount(t *testing.T) {
Steps: []resource.TestStep{
{
Config: hclProviderFor(user) + hclDatasourceSubaccountById("test", "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"),
ExpectError: regexp.MustCompile(`404 Not Found: \[no body\] \[Error: 404\]`), // TODO improve error text
ExpectError: regexp.MustCompile(`Error: API Error Reading Resource Subaccount`),
},
},
})
Expand Down
36 changes: 21 additions & 15 deletions btp/provider/datasource_subaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ var subaccountObjType = types.ObjectType{
},
"region": types.StringType,

"state": types.StringType,
"subdomain": types.StringType,
"usage": types.StringType,
"state": types.StringType,
"subdomain": types.StringType,
"usage": types.StringType,
"contract_status": types.StringType,
},
}

Expand Down Expand Up @@ -178,6 +179,10 @@ You must be assigned to the admin or viewer role of the global account, director
getFormattedValueAsTableRow("`USED_FOR_PRODUCTION`", "The subaccount is used for production purposes."),
Computed: true,
},
"contract_status": schema.StringAttribute{
MarkdownDescription: "Shows the contract status of the subaccount.",
Computed: true,
},
},
},
MarkdownDescription: "The subaccounts contained in the global account.",
Expand Down Expand Up @@ -212,18 +217,19 @@ func (ds *subaccountsDataSource) Read(ctx context.Context, req datasource.ReadRe

for _, subaccountRes := range cliRes.Value {
c := subaccountDataSourceType{
ID: types.StringValue(subaccountRes.Guid),
BetaEnabled: types.BoolValue(subaccountRes.BetaEnabled),
CreatedBy: types.StringValue(subaccountRes.CreatedBy),
CreatedDate: timeToValue(subaccountRes.CreatedDate.Time()),
Description: types.StringValue(subaccountRes.Description),
LastModified: timeToValue(subaccountRes.ModifiedDate.Time()),
Name: types.StringValue(subaccountRes.DisplayName),
ParentID: types.StringValue(subaccountRes.ParentGUID),
Region: types.StringValue(subaccountRes.Region),
State: types.StringValue(subaccountRes.State),
Subdomain: types.StringValue(subaccountRes.Subdomain),
Usage: types.StringValue(subaccountRes.UsedForProduction),
ID: types.StringValue(subaccountRes.Guid),
BetaEnabled: types.BoolValue(subaccountRes.BetaEnabled),
CreatedBy: types.StringValue(subaccountRes.CreatedBy),
CreatedDate: timeToValue(subaccountRes.CreatedDate.Time()),
Description: types.StringValue(subaccountRes.Description),
LastModified: timeToValue(subaccountRes.ModifiedDate.Time()),
Name: types.StringValue(subaccountRes.DisplayName),
ParentID: types.StringValue(subaccountRes.ParentGUID),
Region: types.StringValue(subaccountRes.Region),
State: types.StringValue(subaccountRes.State),
Subdomain: types.StringValue(subaccountRes.Subdomain),
Usage: types.StringValue(subaccountRes.UsedForProduction),
ContractStatus: types.StringValue(subaccountRes.ContractStatus),
}

c.Labels, diags = types.MapValueFrom(ctx, types.SetType{ElemType: types.StringType}, subaccountRes.Labels)
Expand Down
2 changes: 1 addition & 1 deletion btp/provider/datasource_subaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestDataSourceSubaccounts(t *testing.T) {
{
Config: hclProviderFor(user) + hclDatasourceSubaccounts("uut"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.btp_subaccounts.uut", "values.#", "9"),
resource.TestCheckResourceAttr("data.btp_subaccounts.uut", "values.#", "10"),
),
},
},
Expand Down
Loading
Loading