diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 559b451..51acdaa 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.36.1" + ".": "0.37.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index c875efd..b154e7a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 101 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ea5c9cb25c29fa5a8758bbf8732eb306783bb6f13b4df29bf1ad5ad3cb32da1e.yml -openapi_spec_hash: 597031840469b011f5cf22a4d8b9d750 -config_hash: 147340811dd6fbb9c2d80515a7e31f9a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-fc4a441d80d9a26574ef8af390a0c76265f5d4190daf90a04b6b353b128bbd97.yml +openapi_spec_hash: 192987649d3797c3a80e6ef201667b64 +config_hash: 8af430e19f4af86c05f2987241cae72f diff --git a/CHANGELOG.md b/CHANGELOG.md index 074c6a5..64dfea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.37.0 (2026-02-23) + +Full Changelog: [v0.36.1...v0.37.0](https://github.com/kernel/kernel-go-sdk/compare/v0.36.1...v0.37.0) + +### Features + +* Neil/kernel 1017 profile pagination query parameter ([d6166c8](https://github.com/kernel/kernel-go-sdk/commit/d6166c8793e9ad1e28d97b211af802d0abc87461)) + + +### Bug Fixes + +* improve CLI coverage workflow reliability and accuracy ([4dac142](https://github.com/kernel/kernel-go-sdk/commit/4dac142d082cec5ac906426e9edb00bc6b0c1693)) +* remove racy branch existence check in CLI coverage workflow ([32639df](https://github.com/kernel/kernel-go-sdk/commit/32639df54540df7e4d15c32092a565d20b32718e)) + ## 0.36.1 (2026-02-21) Full Changelog: [v0.36.0...v0.36.1](https://github.com/kernel/kernel-go-sdk/compare/v0.36.0...v0.36.1) diff --git a/README.md b/README.md index 570692b..d56eecf 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Or to pin the version: ```sh -go get -u 'github.com/kernel/kernel-go-sdk@v0.36.1' +go get -u 'github.com/kernel/kernel-go-sdk@v0.37.0' ``` diff --git a/api.md b/api.md index 59aa425..ff2e833 100644 --- a/api.md +++ b/api.md @@ -204,7 +204,7 @@ Methods: - client.Profiles.New(ctx context.Context, body kernel.ProfileNewParams) (\*kernel.Profile, error) - client.Profiles.Get(ctx context.Context, idOrName string) (\*kernel.Profile, error) -- client.Profiles.List(ctx context.Context) (\*[]kernel.Profile, error) +- client.Profiles.List(ctx context.Context, query kernel.ProfileListParams) (\*pagination.OffsetPagination[kernel.Profile], error) - client.Profiles.Delete(ctx context.Context, idOrName string) error - client.Profiles.Download(ctx context.Context, idOrName string) (\*http.Response, error) diff --git a/internal/version.go b/internal/version.go index e8d781a..23009ef 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.36.1" // x-release-please-version +const PackageVersion = "0.37.0" // x-release-please-version diff --git a/profile.go b/profile.go index 0e66134..15f9cec 100644 --- a/profile.go +++ b/profile.go @@ -7,11 +7,14 @@ import ( "errors" "fmt" "net/http" + "net/url" "slices" "github.com/kernel/kernel-go-sdk/internal/apijson" + "github.com/kernel/kernel-go-sdk/internal/apiquery" "github.com/kernel/kernel-go-sdk/internal/requestconfig" "github.com/kernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk/packages/pagination" "github.com/kernel/kernel-go-sdk/packages/param" ) @@ -56,11 +59,26 @@ func (r *ProfileService) Get(ctx context.Context, idOrName string, opts ...optio } // List profiles with optional filtering and pagination. -func (r *ProfileService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Profile, err error) { +func (r *ProfileService) List(ctx context.Context, query ProfileListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[Profile], err error) { + var raw *http.Response opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "profiles" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List profiles with optional filtering and pagination. +func (r *ProfileService) ListAutoPaging(ctx context.Context, query ProfileListParams, opts ...option.RequestOption) *pagination.OffsetPaginationAutoPager[Profile] { + return pagination.NewOffsetPaginationAutoPager(r.List(ctx, query, opts...)) } // Delete a profile by its ID or by its name. @@ -103,3 +121,21 @@ func (r ProfileNewParams) MarshalJSON() (data []byte, err error) { func (r *ProfileNewParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +type ProfileListParams struct { + // Limit the number of profiles to return. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Offset the number of profiles to return. + Offset param.Opt[int64] `query:"offset,omitzero" json:"-"` + // Search profiles by name or ID. + Query param.Opt[string] `query:"query,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [ProfileListParams]'s query parameters as `url.Values`. +func (r ProfileListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/profile_test.go b/profile_test.go index 3b8e043..179bf75 100644 --- a/profile_test.go +++ b/profile_test.go @@ -65,7 +65,7 @@ func TestProfileGet(t *testing.T) { } } -func TestProfileList(t *testing.T) { +func TestProfileListWithOptionalParams(t *testing.T) { t.Skip("Mock server tests are disabled") baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { @@ -78,7 +78,11 @@ func TestProfileList(t *testing.T) { option.WithBaseURL(baseURL), option.WithAPIKey("My API Key"), ) - _, err := client.Profiles.List(context.TODO()) + _, err := client.Profiles.List(context.TODO(), kernel.ProfileListParams{ + Limit: kernel.Int(1), + Offset: kernel.Int(0), + Query: kernel.String("query"), + }) if err != nil { var apierr *kernel.Error if errors.As(err, &apierr) {