Hey, we have built a provider using the boilerplat...
# general
p
Hey, we have built a provider using the boilerplate repo but have hit a snag trying to understand how to Invoke functions. I understand how to generate and call the code, but what I don’t understand is how to build the rpc.InvokeResponse that I need to return.
Im calling listTeams that needs to return as follows:
Copy code
map[string]schema.FunctionSpec{
	"tsb:api:listTeams": {
		Outputs: &schema.ObjectTypeSpec{
			Properties: map[string]schema.PropertySpec{
				"teams": {
					TypeSpec: schema.TypeSpec{
						Type: "array",
						Items: &schema.TypeSpec{
							Type: "object",
							Ref:  "#/types/tsb:types:Team",
						},
					},
				},
			},
		},
	},
}
currently I get
Copy code
Error: invocation of tsb:api:listTeams returned an error: proto: invalid type: *structpb.Struct
how Im converting:
Copy code
genericsPlz := make([]interface{}, 0)
		for _, resp := range responses {
			props, err := plugin.MarshalProperties(
				resource.NewPropertyMap(&resp),
				plugin.MarshalOptions{KeepUnknowns: true, SkipNulls: true},
			)
			if err != nil {
				return nil, err
			}
			genericsPlz = append(genericsPlz, props)
		}
		list, convErr := structpb.NewList(genericsPlz)
		if convErr != nil {
			return nil, convErr
		}
		ret, err = structpb.NewStruct(map[string]interface{}{"teams": list})
b
-0 c. gtrft]