No go. I still get a Value Conversion Error using the types.Object. Here’s what I originally have for the structs:
type botDataSourceModel struct {
ID types.String `tfsdk:"resource_id"`
Name types.String `tfsdk:"name"`
Description types.String `tfsdk:"description"`
Owner types.String `tfsdk:"owner"`
OwnerName types.String `tfsdk:"owner_name"`
Scope types.Set `tfsdk:"scope"`
Severity types.String `tfsdk:"severity"`
State types.String `tfsdk:"state"`
Instructions botInstructionsModel `tfsdk:"instructions"`
}
type botInstructionsModel struct {
Actions []botActionsModel `tfsdk:"actions"`
Badges []badgesModel `tfdsk:"badges"`
ExclusionBadges []badgesModel `tfsdk:"exclusion_badges"`
Filters []filtersModel `tfsdk:"filters"`
Groups types.Set `tfsdk:"groups"`
Hookpoints types.Set `tfsdk:"hookpoints"`
ResourceTypes types.Set `tfsdk:"resource_types"`
Schedule types.String `tfsdk:"schedule"`
ScheduleDescription types.String `tfsdk:"schedule_description"`
}
type botActionsModel struct {
Name types.String `tfsdk:"name"`
Config types.Map `tfsdk:"config"`
RunWhenResultIs types.Bool `tfsdk:"run_when_result_is"`
}
And here’s the schema definitions:
func (d *botDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"resource_id": schema.StringAttribute{
Required: true,
Description: "Bot ID",
MarkdownDescription: "The bot ID associated with the bot to return. For example: divvybot:1:123.",
},
"name": schema.StringAttribute{
Computed: true,
Description: "Bot Name",
MarkdownDescription: "The name of the bot.",
},
"description": schema.StringAttribute{
Computed: true,
Description: "Description of the bot",
MarkdownDescription: "The description given to the bot.",
},
"severity": schema.StringAttribute{
Computed: true,
Description: "Severity of the bot",
MarkdownDescription: "The severity given to the bot.",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("low", "medium", "high"),
},
},
"owner": schema.StringAttribute{
Computed: true,
Description: "Bot Owner",
MarkdownDescription: "The bot owner's account.",
},
"owner_name": schema.StringAttribute{
Computed: true,
Description: "Bot Owner's Name",
MarkdownDescription: "The bot owner's name.",
},
"scope": schema.SetAttribute{
Computed: true,
Description: "Scope for the bot",
MarkdownDescription: "Scopes of the given bot.",
ElementType: types.StringType,
},
"state": schema.StringAttribute{
Computed: true,
Description: "Current State of the bot",
MarkdownDescription: "The current state given to the bot.",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("paused", "running"),
},
},
"instructions": schema.SingleNestedAttribute{
Computed: true,
Description: "Bot Instructions",
MarkdownDescription: "The bot instructions that define how the bot is to operate and on what.",
Attributes: map[string]schema.Attribute{
"actions": schema.ListNestedAttribute{
Computed: true,
Description: "Bot actions",
MarkdownDescription: "The actions the bot is to take when run.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Computed: true,
Description: "Action's Name",
MarkdownDescription: "The name of the bot action.",
},
"config": schema.MapAttribute{
Computed: true,
Description: "Configs for the filter",
MarkdownDescription: "Configuration settings for the given filter.",
ElementType: types.StringType,
},
"run_when_result_is": schema.BoolAttribute{
Computed: true,
Description: "Run when the result is",
MarkdownDescription: "Run the action when result is true or false.",
},
},
},
},
"badges": schema.ListNestedAttribute{
Computed: true,
Description: "Badges applied to the bot",
MarkdownDescription: "The badges applied to the bot.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Computed: true,
},
"value": schema.StringAttribute{
Computed: true,
},
},
},
},
"exclusion_badges": schema.ListNestedAttribute{
Computed: true,
Description: "Excluded badges for the bot",
MarkdownDescription: "The badges that are excluded from this bot.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Computed: true,
},
"value": schema.StringAttribute{
Computed: true,
},
},
},
},
"filters": schema.ListNestedAttribute{
Computed: true,
Description: "Filters applied to the bot.",
MarkdownDescription: "The filters used to query resources in the bot.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Computed: true,
Description: "Filter name",
MarkdownDescription: "The name of the filter",
},
"config": schema.MapAttribute{
Computed: true,
Description: "Configs for the filter",
MarkdownDescription: "Configuration settings for the given filter.",
ElementType: types.StringType,
},
},
},
},
"groups": schema.SetAttribute{
Computed: true,
Description: "Groups to apply the bot",
MarkdownDescription: "Groups to apply the bot.",
ElementType: types.StringType,
},
"hookpoints": schema.SetAttribute{
Computed: true,
Description: "Hookpoints for the bot",
MarkdownDescription: "Hookpoints for the bot.",
ElementType: types.StringType,
},
"resource_types": schema.SetAttribute{
Computed: true,
Description: "Resource types used for the bot",
MarkdownDescription: "Resource types used for the bot.",
ElementType: types.StringType,
},
"schedule": schema.StringAttribute{
Computed: true,
Description: "Bot Schedule",
MarkdownDescription: "A string represnting a json object for the bot's schedule.",
},
"schedule_description": schema.StringAttribute{
Computed: true,
Description: "Bot Schedule Description",
MarkdownDescription: "A string represnting a json object for the bot's schedule description.",
},
},
},
},
}
}