internal/mcp: resource template iterator
Add Client.ResourceTemplates Test forthcoming. Change-Id: I35e8ee8fabdf8fa216456ab3fcd0c8a7de9287c8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/680255 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
This commit is contained in:
parent
c1524fe934
commit
4c543514c4
1 changed files with 13 additions and 0 deletions
|
|
@ -383,6 +383,19 @@ func (cs *ClientSession) Resources(ctx context.Context, params *ListResourcesPar
|
|||
})
|
||||
}
|
||||
|
||||
// ResourceTemplates provides an iterator for all resource templates available on the server,
|
||||
// automatically fetching pages and managing cursors.
|
||||
// The `params` argument can set the initial cursor.
|
||||
// Iteration stops at the first encountered error, which will be yielded.
|
||||
func (cs *ClientSession) ResourceTemplates(ctx context.Context, params *ListResourceTemplatesParams) iter.Seq2[ResourceTemplate, error] {
|
||||
if params == nil {
|
||||
params = &ListResourceTemplatesParams{}
|
||||
}
|
||||
return paginate(ctx, params, cs.ListResourceTemplates, func(res *ListResourceTemplatesResult) []*ResourceTemplate {
|
||||
return res.ResourceTemplates
|
||||
})
|
||||
}
|
||||
|
||||
// Prompts provides an iterator for all prompts available on the server,
|
||||
// automatically fetching pages and managing cursors.
|
||||
// The `params` argument can set the initial cursor.
|
||||
|
|
|
|||
Loading…
Reference in a new issue