From b0562af1fcfab20d43ce8f13d2e561fb80e1da42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Olivi=C3=A9?= Date: Mon, 2 Feb 2026 21:16:59 +0000 Subject: [PATCH 1/2] Add search endpoint for app meta --- invopop/silo_meta.go | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/invopop/silo_meta.go b/invopop/silo_meta.go index 9bb8c9c..6b30ca6 100644 --- a/invopop/silo_meta.go +++ b/invopop/silo_meta.go @@ -4,7 +4,9 @@ import ( "context" "encoding/json" "errors" + "net/url" "path" + "strconv" ) const ( @@ -15,6 +17,22 @@ const ( // the special "enrolled" scope in tokens. type SiloMetaService service +// SiloMetaCollection contains a list of Meta entries with pagination. +type SiloMetaCollection struct { + List []*SiloMeta `json:"list"` + Limit int32 `json:"limit"` + Offset int32 `json:"offset"` +} + +// FindMetaBySrc is used to query meta entries by source and key. +type FindMetaBySrc struct { + Key string `query:"key" title:"Key" description:"Key used to identify the meta entries." example:"service-id"` + IncludeSecure bool `query:"include_secure" title:"Include Secure" description:"When true, secure meta entries are included in results." example:"false"` + Shared bool `query:"shared" title:"Shared" description:"When true, only shared meta entries are returned." example:"false"` + Limit int32 `query:"limit" title:"Limit" description:"Maximum number of entries to return." example:"100"` + Offset int32 `query:"offset" title:"Offset" description:"Number of entries to skip." example:"0"` +} + // SiloMeta describes a meta row embedded inside a Silo Entry. type SiloMeta struct { ID string `json:"id" title:"ID" description:"Compound ID of the meta row." example:"347c5b04-cde2-11ed-afa1-0242ac120002:source:key"` @@ -49,6 +67,33 @@ type UpsertSiloMeta struct { Shared bool `json:"shared,omitempty" title:"Shared" description:"When true, the meta entry can be shared with other applications." example:"true"` } +// Find retrieves meta entries by source and key with pagination support. +// The source is determined by the authentication token's app ID. +func (s *SiloMetaService) Find(ctx context.Context, req *FindMetaBySrc) (*SiloMetaCollection, error) { + if req.Key == "" { + return nil, errors.New("missing key") + } + p := path.Join(siloBasePath, entriesPath, metaPath, req.Key) + query := make(url.Values) + if req.IncludeSecure { + query.Add("include_secure", "true") + } + if req.Shared { + query.Add("shared", "true") + } + if req.Limit != 0 { + query.Add("limit", strconv.Itoa(int(req.Limit))) + } + if req.Offset != 0 { + query.Add("offset", strconv.Itoa(int(req.Offset))) + } + if len(query) > 0 { + p = p + "?" + query.Encode() + } + col := new(SiloMetaCollection) + return col, s.client.get(ctx, p, col) +} + // Fetch retrieves a meta row by its key. func (s *SiloMetaService) Fetch(ctx context.Context, entryID, key string) (*SiloMeta, error) { if entryID == "" { From c2c14acc7814150de7d582c19f74812c1f133ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Olivi=C3=A9?= Date: Tue, 3 Feb 2026 19:27:17 +0000 Subject: [PATCH 2/2] Add cursor to call instead of offset --- invopop/silo_meta.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/invopop/silo_meta.go b/invopop/silo_meta.go index 6b30ca6..73f28c5 100644 --- a/invopop/silo_meta.go +++ b/invopop/silo_meta.go @@ -19,9 +19,10 @@ type SiloMetaService service // SiloMetaCollection contains a list of Meta entries with pagination. type SiloMetaCollection struct { - List []*SiloMeta `json:"list"` - Limit int32 `json:"limit"` - Offset int32 `json:"offset"` + List []*SiloMeta `json:"list"` + Limit int32 `json:"limit"` + Cursor string `json:"cursor,omitempty"` + NextCursor string `json:"next_cursor,omitempty"` } // FindMetaBySrc is used to query meta entries by source and key. @@ -30,7 +31,7 @@ type FindMetaBySrc struct { IncludeSecure bool `query:"include_secure" title:"Include Secure" description:"When true, secure meta entries are included in results." example:"false"` Shared bool `query:"shared" title:"Shared" description:"When true, only shared meta entries are returned." example:"false"` Limit int32 `query:"limit" title:"Limit" description:"Maximum number of entries to return." example:"100"` - Offset int32 `query:"offset" title:"Offset" description:"Number of entries to skip." example:"0"` + Cursor string `query:"cursor" title:"Cursor" description:"Position provided by the previous result's next_cursor property."` } // SiloMeta describes a meta row embedded inside a Silo Entry. @@ -84,8 +85,8 @@ func (s *SiloMetaService) Find(ctx context.Context, req *FindMetaBySrc) (*SiloMe if req.Limit != 0 { query.Add("limit", strconv.Itoa(int(req.Limit))) } - if req.Offset != 0 { - query.Add("offset", strconv.Itoa(int(req.Offset))) + if req.Cursor != "" { + query.Add("cursor", req.Cursor) } if len(query) > 0 { p = p + "?" + query.Encode()