Skip to content

Commit

Permalink
Switch sdkv2 schemas to SchemaFunc (#2034)
Browse files Browse the repository at this point in the history
* datasource use SchemaFunc

* switch Schema to SchemaFunc
  • Loading branch information
skarimo authored Jul 27, 2023
1 parent dc7de43 commit fc47d78
Show file tree
Hide file tree
Showing 76 changed files with 3,341 additions and 3,179 deletions.
38 changes: 20 additions & 18 deletions datadog/data_source_datadog_application_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ func dataSourceDatadogApplicationKey() *schema.Resource {
Description: "Use this data source to retrieve information about an existing application key.",
ReadContext: dataSourceDatadogApplicationKeyRead,

Schema: map[string]*schema.Schema{
"id": {
Description: "Id for Application Key.",
Type: schema.TypeString,
Optional: true,
},
"name": {
Description: "Name for Application Key.",
Type: schema.TypeString,
Optional: true,
},
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
"id": {
Description: "Id for Application Key.",
Type: schema.TypeString,
Optional: true,
},
"name": {
Description: "Name for Application Key.",
Type: schema.TypeString,
Optional: true,
},

// Computed values
"key": {
Description: "The value of the Application Key.",
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
// Computed values
"key": {
Description: "The value of the Application Key.",
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
}
},
}
}
Expand Down
68 changes: 35 additions & 33 deletions datadog/data_source_datadog_cloud_workload_security_agent_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,44 @@ func dataSourceDatadogCloudWorkloadSecurityAgentRules() *schema.Resource {
Description: "Use this data source to retrieve information about existing Cloud Workload Security Agent Rules for use in other resources.",
ReadContext: dataSourceDatadogCloudWorkloadSecurityAgentRulesRead,

Schema: map[string]*schema.Schema{
// Computed
"agent_rules": {
Description: "List of Agent rules.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the Agent rule.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "The description of the Agent rule.",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the Agent rule is enabled.",
},
"expression": {
Type: schema.TypeString,
Computed: true,
Description: "The SECL expression of the Agent rule.",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the Agent rule.",
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
// Computed
"agent_rules": {
Description: "List of Agent rules.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the Agent rule.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "The description of the Agent rule.",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the Agent rule is enabled.",
},
"expression": {
Type: schema.TypeString,
Computed: true,
Description: "The SECL expression of the Agent rule.",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the Agent rule.",
},
},
},
},
},
}
},
}
}
Expand Down
38 changes: 20 additions & 18 deletions datadog/data_source_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@ func dataSourceDatadogDashboard() *schema.Resource {
Description: "Use this data source to retrieve information about an existing dashboard, for use in other resources. In particular, it can be used in a monitor message to link to a specific dashboard.",
ReadContext: dataSourceDatadogDashboardRead,

Schema: map[string]*schema.Schema{
"name": {
Description: "The dashboard name to search for. Must only match one dashboard.",
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
// Computed values
"title": {
Description: "The name of the dashboard.",
Type: schema.TypeString,
Computed: true,
},
"url": {
Description: "The URL to a specific dashboard.",
Type: schema.TypeString,
Computed: true,
},
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
"name": {
Description: "The dashboard name to search for. Must only match one dashboard.",
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
// Computed values
"title": {
Description: "The name of the dashboard.",
Type: schema.TypeString,
Computed: true,
},
"url": {
Description: "The URL to a specific dashboard.",
Type: schema.TypeString,
Computed: true,
},
}
},
}
}
Expand Down
16 changes: 9 additions & 7 deletions datadog/data_source_datadog_dashboard_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ func dataSourceDatadogDashboardList() *schema.Resource {
Description: "Use this data source to retrieve information about an existing dashboard list, for use in other resources. In particular, it can be used in a dashboard to register it in the list.",
ReadContext: dataSourceDatadogDashboardListRead,

Schema: map[string]*schema.Schema{
"name": {
Description: "A dashboard list name to limit the search.",
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
"name": {
Description: "A dashboard list name to limit the search.",
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
}
},
}
}
Expand Down
38 changes: 20 additions & 18 deletions datadog/data_source_datadog_integration_aws_logs_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@ func dataSourceDatadogIntegrationAWSLogsServices() *schema.Resource {
return &schema.Resource{
Description: "Use this data source to retrieve all AWS log ready services.",
ReadContext: dataSourceDatadogIntegrationAWSLogsServicesRead,
Schema: map[string]*schema.Schema{
// Computed
"aws_logs_services": {
Description: "List of AWS log ready services.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the AWS log service.",
},
"label": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the AWS log service.",
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
// Computed
"aws_logs_services": {
Description: "List of AWS log ready services.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the AWS log service.",
},
"label": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the AWS log service.",
},
},
},
},
},
}
},
}
}
Expand Down
18 changes: 10 additions & 8 deletions datadog/data_source_datadog_logs_archives_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ func dataSourceDatadogLogsArchivesOrder() *schema.Resource {
Description: "Get the current order of your logs archives.",
ReadContext: dataSourceDatadogLogsArchivesOrderRead,

Schema: map[string]*schema.Schema{
// Computed values
"archive_ids": {
Description: "The archive IDs list. The order of archive IDs in this attribute defines the overall archive order for logs.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
// Computed values
"archive_ids": {
Description: "The archive IDs list. The order of archive IDs in this attribute defines the overall archive order for logs.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}
},
}
}
Expand Down
85 changes: 44 additions & 41 deletions datadog/data_source_datadog_logs_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,57 @@ func dataSourceDatadogLogsIndexes() *schema.Resource {
return &schema.Resource{
Description: "Use this data source to list several existing logs indexes for use in other resources.",
ReadContext: dataSourceDatadogLogsIndexesRead,
Schema: map[string]*schema.Schema{
// Computed values
"logs_indexes": {
Description: "List of logs indexes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Description: "The name of the index.",
Type: schema.TypeString,
Computed: true,
},
"daily_limit": {
Description: "The number of log events you can send in this index per day before you are rate-limited.",
Type: schema.TypeInt,
Computed: true,
},
"retention_days": {
Description: "The number of days before logs are deleted from this index.",
Type: schema.TypeInt,
Computed: true,
},
"filter": {
Description: "Logs filter",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"query": {
Description: "Logs filter criteria. Only logs matching this filter criteria are considered for this index.",
Type: schema.TypeString,
Required: true,

SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
// Computed values
"logs_indexes": {
Description: "List of logs indexes",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Description: "The name of the index.",
Type: schema.TypeString,
Computed: true,
},
"daily_limit": {
Description: "The number of log events you can send in this index per day before you are rate-limited.",
Type: schema.TypeInt,
Computed: true,
},
"retention_days": {
Description: "The number of days before logs are deleted from this index.",
Type: schema.TypeInt,
Computed: true,
},
"filter": {
Description: "Logs filter",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"query": {
Description: "Logs filter criteria. Only logs matching this filter criteria are considered for this index.",
Type: schema.TypeString,
Required: true,
},
},
},
},
},
"exclusion_filter": {
Description: "List of exclusion filters.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceLogsIndexesExclusionFilterSchema,
"exclusion_filter": {
Description: "List of exclusion filters.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceLogsIndexesExclusionFilterSchema,
},
},
},
},
},
},
}
},
}
}
Expand Down
18 changes: 10 additions & 8 deletions datadog/data_source_datadog_logs_indexes_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ func dataSourceDatadogLogsIndexesOrder() *schema.Resource {
Description: "Get the current order of your log indexes.",
ReadContext: dataSourceDatadogLogsIndexesOrderRead,

Schema: map[string]*schema.Schema{
// Computed values
"index_names": {
Description: "Array of strings identifying by their name(s) the index(es) of your organization. Logs are tested against the query filter of each index one by one, following the order of the array. Logs are eventually stored in the first matching index.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
// Computed values
"index_names": {
Description: "Array of strings identifying by their name(s) the index(es) of your organization. Logs are tested against the query filter of each index one by one, following the order of the array. Logs are eventually stored in the first matching index.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}
},
}
}
Expand Down
Loading

0 comments on commit fc47d78

Please sign in to comment.