Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datadog_powerpack] Re-introduce powerpack resource #2187

Merged
merged 15 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
9 changes: 9 additions & 0 deletions datadog/internal/utils/api_instances_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type ApiInstances struct {
opsgenieIntegrationApiV2 *datadogV2.OpsgenieIntegrationApi
organizationsApiV2 *datadogV2.OrganizationsApi
processesApiV2 *datadogV2.ProcessesApi
powerpackApiV2 *datadogV2.PowerpackApi
restrictionPolicyApiV2 *datadogV2.RestrictionPoliciesApi
rolesApiV2 *datadogV2.RolesApi
rumApiV2 *datadogV2.RUMApi
Expand Down Expand Up @@ -488,6 +489,14 @@ func (i *ApiInstances) GetProcessesApiV2() *datadogV2.ProcessesApi {
return i.processesApiV2
}

// GetPowerpackApiV2 get instance of PowerpackApi
func (i *ApiInstances) GetPowerpackApiV2() *datadogV2.PowerpackApi {
if i.powerpackApiV2 == nil {
i.powerpackApiV2 = datadogV2.NewPowerpackApi(i.HttpClient)
}
return i.powerpackApiV2
}

// GetRolesApiV2 get instance of RolesApi
func (i *ApiInstances) GetRolesApiV2() *datadogV2.RolesApi {
if i.rolesApiV2 == nil {
Expand Down
1 change: 1 addition & 0 deletions datadog/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func Provider() *schema.Provider {
"datadog_monitor_config_policy": resourceDatadogMonitorConfigPolicy(),
"datadog_monitor_json": resourceDatadogMonitorJSON(),
"datadog_organization_settings": resourceDatadogOrganizationSettings(),
"datadog_powerpack": resourceDatadogPowerpack(),
"datadog_role": resourceDatadogRole(),
"datadog_rum_application": resourceDatadogRUMApplication(),
"datadog_service_account": resourceDatadogServiceAccount(),
Expand Down
18 changes: 12 additions & 6 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func buildTerraformNotifyList(datadogNotifyList *[]string) *[]string {
// The generic widget schema is a combination of the schema for a non-group widget
// and the schema for a Group Widget (which can contains only non-group widgets)
func getWidgetSchema() map[string]*schema.Schema {
widgetSchema := getNonGroupWidgetSchema()
widgetSchema := getNonGroupWidgetSchema(false)
widgetSchema["group_definition"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand All @@ -708,8 +708,8 @@ func getWidgetSchema() map[string]*schema.Schema {
return widgetSchema
}

func getNonGroupWidgetSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
func getNonGroupWidgetSchema(isPowerpackSchema bool) map[string]*schema.Schema {
s := map[string]*schema.Schema{
"widget_layout": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -995,16 +995,22 @@ func getNonGroupWidgetSchema() map[string]*schema.Schema {
Schema: getRunWorkflowDefinitionSchema(),
},
},
"split_graph_definition": {
}

// Non powerpack specific widgets
if !isPowerpackSchema {
s["split_graph_definition"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "The definition for a Split Graph widget.",
Elem: &schema.Resource{
Schema: getSplitGraphDefinitionSchema(),
},
},
}
}

return s
}

func getSplitGraphSourceWidgetSchema() map[string]*schema.Schema {
Expand Down Expand Up @@ -1598,7 +1604,7 @@ func getGroupDefinitionSchema() map[string]*schema.Schema {
Optional: true,
Description: "The list of widgets in this group.",
Elem: &schema.Resource{
Schema: getNonGroupWidgetSchema(),
Schema: getNonGroupWidgetSchema(false),
},
},
"layout_type": {
Expand Down
Loading