Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.150.0"
".": "0.151.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 189
configured_endpoints: 206
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.151.0](https://github.com/kernel/kernel-go-sdk/compare/v0.150.0...v0.151.0) (2026-11-19)


### Features

* Add service account, workload identity issuer, federation rule and authentication event resources. They require a signed-in session; API keys get 403 ([10f570a](https://github.com/kernel/kernel-go-sdk/commit/10f570a40039088d872b17ffb1a59f7e341931db))
* Add `service_account_id`, `principal_type`, `created_by` and `project_id` filters and the `expired` status to API key listing. `status=active`, the default, no longer returns expired keys ([10f570a](https://github.com/kernel/kernel-go-sdk/commit/10f570a40039088d872b17ffb1a59f7e341931db))
* Change `APIKeyPrincipal.Type`, which 0.150.0 introduced as a `string`, to the new `APIKeyPrincipalType` ([10f570a](https://github.com/kernel/kernel-go-sdk/commit/10f570a40039088d872b17ffb1a59f7e341931db))

## [0.150.0](https://github.com/kernel/kernel-go-sdk/compare/v0.149.0...v0.150.0) (2026-11-19)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/kernel/kernel-go-sdk@v0.150.0'
go get -u 'github.com/kernel/kernel-go-sdk@v0.151.0'
```

<!-- x-release-please-end -->
Expand Down
80 changes: 80 additions & 0 deletions api.md

Large diffs are not rendered by default.

44 changes: 36 additions & 8 deletions apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (r *APIKeyPolicyStatementCondition) UnmarshalJSON(data []byte) error {
type APIKeyPrincipal struct {
ID string `json:"id" api:"required"`
// Any of "user", "service_account".
Type string `json:"type" api:"required"`
Type APIKeyPrincipalType `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Expand All @@ -323,6 +323,13 @@ func (r *APIKeyPrincipal) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type APIKeyPrincipalType string

const (
APIKeyPrincipalTypeUser APIKeyPrincipalType = "user"
APIKeyPrincipalTypeServiceAccount APIKeyPrincipalType = "service_account"
)

// API key returned immediately after creation. Includes the plaintext key once.
type CreatedAPIKey struct {
// Plaintext API key. Only returned once when the key is created.
Expand Down Expand Up @@ -567,6 +574,9 @@ func init() {
}

type APIKeyListParams struct {
// Return only keys created by this user ID. This is the same person the key's
// created_by field describes.
CreatedBy param.Opt[string] `query:"created_by,omitzero" json:"-"`
// Deprecated: use status=all instead. When true, include deleted (soft-deleted)
// API keys in the results for audit purposes.
IncludeDeleted param.Opt[bool] `query:"include_deleted,omitzero" json:"-"`
Expand All @@ -579,9 +589,18 @@ type APIKeyListParams struct {
Name param.Opt[string] `query:"name,omitzero" json:"-"`
// Number of results to skip
Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
// Return only keys scoped to this project ID. The value "org" returns keys that
// are not scoped to a project.
ProjectID param.Opt[string] `query:"project_id,omitzero" json:"-"`
// Case-insensitive substring match against API key name, creator, and project. API
// key identifiers and masked keys match by exact value or prefix.
Query param.Opt[string] `query:"query,omitzero" json:"-"`
// Return only keys that belong to this service account.
ServiceAccountID param.Opt[string] `query:"service_account_id,omitzero" json:"-"`
// Return only keys that act as a user, or only keys that act as a service account.
//
// Any of "user", "service_account".
PrincipalType APIKeyListParamsPrincipalType `query:"principal_type,omitzero" json:"-"`
// Field to sort API keys by. Keys with no expiry or no recorded use sort last for
// expires_at and last_used_at in either direction.
//
Expand All @@ -591,11 +610,11 @@ type APIKeyListParams struct {
//
// Any of "asc", "desc".
SortDirection APIKeyListParamsSortDirection `query:"sort_direction,omitzero" json:"-"`
// Filter API keys by status. "active" returns keys that are not deleted (default;
// expired-but-not-deleted keys are still included), "deleted" returns only
// soft-deleted keys, "all" returns both.
// Filter API keys by status. "active" returns keys that are neither deleted nor
// expired (default), "expired" returns keys that are not deleted and whose expiry
// has passed, "deleted" returns only soft-deleted keys, "all" returns every key.
//
// Any of "active", "deleted", "all".
// Any of "active", "expired", "deleted", "all".
Status APIKeyListParamsStatus `query:"status,omitzero" json:"-"`
paramObj
}
Expand All @@ -608,6 +627,14 @@ func (r APIKeyListParams) URLQuery() (v url.Values, err error) {
})
}

// Return only keys that act as a user, or only keys that act as a service account.
type APIKeyListParamsPrincipalType string

const (
APIKeyListParamsPrincipalTypeUser APIKeyListParamsPrincipalType = "user"
APIKeyListParamsPrincipalTypeServiceAccount APIKeyListParamsPrincipalType = "service_account"
)

// Field to sort API keys by. Keys with no expiry or no recorded use sort last for
// expires_at and last_used_at in either direction.
type APIKeyListParamsSortBy string
Expand All @@ -627,13 +654,14 @@ const (
APIKeyListParamsSortDirectionDesc APIKeyListParamsSortDirection = "desc"
)

// Filter API keys by status. "active" returns keys that are not deleted (default;
// expired-but-not-deleted keys are still included), "deleted" returns only
// soft-deleted keys, "all" returns both.
// Filter API keys by status. "active" returns keys that are neither deleted nor
// expired (default), "expired" returns keys that are not deleted and whose expiry
// has passed, "deleted" returns only soft-deleted keys, "all" returns every key.
type APIKeyListParamsStatus string

const (
APIKeyListParamsStatusActive APIKeyListParamsStatus = "active"
APIKeyListParamsStatusExpired APIKeyListParamsStatus = "expired"
APIKeyListParamsStatusDeleted APIKeyListParamsStatus = "deleted"
APIKeyListParamsStatusAll APIKeyListParamsStatus = "all"
)
Expand Down
20 changes: 12 additions & 8 deletions apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ func TestAPIKeyListWithOptionalParams(t *testing.T) {
option.WithAPIKey("My API Key"),
)
_, err := client.APIKeys.List(context.TODO(), kernel.APIKeyListParams{
IncludeDeleted: kernel.Bool(true),
Limit: kernel.Int(100),
Name: kernel.String("name"),
Offset: kernel.Int(0),
Query: kernel.String("query"),
SortBy: kernel.APIKeyListParamsSortByCreatedAt,
SortDirection: kernel.APIKeyListParamsSortDirectionAsc,
Status: kernel.APIKeyListParamsStatusActive,
CreatedBy: kernel.String("created_by"),
IncludeDeleted: kernel.Bool(true),
Limit: kernel.Int(100),
Name: kernel.String("name"),
Offset: kernel.Int(0),
PrincipalType: kernel.APIKeyListParamsPrincipalTypeUser,
ProjectID: kernel.String("project_id"),
Query: kernel.String("query"),
ServiceAccountID: kernel.String("service_account_id"),
SortBy: kernel.APIKeyListParamsSortByCreatedAt,
SortDirection: kernel.APIKeyListParamsSortDirectionAsc,
Status: kernel.APIKeyListParamsStatusActive,
})
if err != nil {
var apierr *kernel.Error
Expand Down
10 changes: 9 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ type Client struct {
// Read audit log records for the authenticated organization.
AuditLogs AuditLogService
// Create and manage API keys for organization and project-scoped access.
APIKeys APIKeyService
APIKeys APIKeyService
ServiceAccounts ServiceAccountService
WorkloadIdentityIssuers WorkloadIdentityIssuerService
WorkloadIdentityFederationRules WorkloadIdentityFederationRuleService
WorkloadIdentityAuthenticationEvents WorkloadIdentityAuthenticationEventService
// Configure external credential providers like 1Password.
CredentialProviders CredentialProviderService
// Search the web and retrieve content for selected results.
Expand Down Expand Up @@ -124,6 +128,10 @@ func NewClient(opts ...option.RequestOption) (r Client) {
r.Organization = NewOrganizationService(opts...)
r.AuditLogs = NewAuditLogService(opts...)
r.APIKeys = NewAPIKeyService(opts...)
r.ServiceAccounts = NewServiceAccountService(opts...)
r.WorkloadIdentityIssuers = NewWorkloadIdentityIssuerService(opts...)
r.WorkloadIdentityFederationRules = NewWorkloadIdentityFederationRuleService(opts...)
r.WorkloadIdentityAuthenticationEvents = NewWorkloadIdentityAuthenticationEventService(opts...)
r.CredentialProviders = NewCredentialProviderService(opts...)
r.Search = NewSearchService(opts...)

Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.150.0" // x-release-please-version
const PackageVersion = "0.151.0" // x-release-please-version
Loading
Loading