feat: Phase 2 Workstream 3 — Go SDK (github.com/sentryagent/idp-sdk-go)
Single-package agentidp SDK in sdk-go/: - AgentIdPClient composing AgentRegistryClient, CredentialClient, TokenServiceClient, AuditClient — all 14 endpoints covered - Goroutine-safe TokenManager (sync.Mutex) with 60s refresh buffer - AgentIdPError implementing error interface with Code/HTTPStatus/Details - Context-aware: all service methods take context.Context as first arg - doRequest shared helper; token endpoints use form-encoded POST directly - go vet: 0 warnings | staticcheck: 0 warnings - go test ./...: 37/37 passed | coverage: 81.0% (>80% gate) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
131
sdk-go/types.go
Normal file
131
sdk-go/types.go
Normal file
@@ -0,0 +1,131 @@
|
||||
// Package agentidp provides a Go client for the SentryAgent.ai AgentIdP API.
|
||||
// It covers all 14 endpoints across agent registry, credential management,
|
||||
// OAuth 2.0 token operations, and audit log queries.
|
||||
package agentidp
|
||||
|
||||
// Agent is a registered AI agent identity.
|
||||
type Agent struct {
|
||||
AgentID string `json:"agentId"`
|
||||
Email string `json:"email"`
|
||||
AgentType string `json:"agentType"`
|
||||
Version string `json:"version"`
|
||||
Capabilities []string `json:"capabilities"`
|
||||
Owner string `json:"owner"`
|
||||
DeploymentEnv string `json:"deploymentEnv"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// RegisterAgentRequest is the body for POST /api/v1/agents.
|
||||
type RegisterAgentRequest struct {
|
||||
Email string `json:"email"`
|
||||
AgentType string `json:"agentType"`
|
||||
Version string `json:"version"`
|
||||
Capabilities []string `json:"capabilities"`
|
||||
Owner string `json:"owner"`
|
||||
DeploymentEnv string `json:"deploymentEnv"`
|
||||
}
|
||||
|
||||
// UpdateAgentRequest is the body for PATCH /api/v1/agents/:id.
|
||||
// All fields are optional — only non-nil pointer fields are sent.
|
||||
type UpdateAgentRequest struct {
|
||||
AgentType *string `json:"agentType,omitempty"`
|
||||
Version *string `json:"version,omitempty"`
|
||||
Capabilities []string `json:"capabilities,omitempty"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
DeploymentEnv *string `json:"deploymentEnv,omitempty"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// PaginatedAgents is a paginated list of agents.
|
||||
type PaginatedAgents struct {
|
||||
Data []Agent `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// ListAgentsParams contains optional query parameters for ListAgents.
|
||||
type ListAgentsParams struct {
|
||||
Status string
|
||||
AgentType string
|
||||
DeploymentEnv string
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
// Credential is a credential record (ClientSecret is never included).
|
||||
type Credential struct {
|
||||
CredentialID string `json:"credentialId"`
|
||||
ClientID string `json:"clientId"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
ExpiresAt *string `json:"expiresAt"`
|
||||
RevokedAt *string `json:"revokedAt"`
|
||||
}
|
||||
|
||||
// CredentialWithSecret is a Credential with a one-time plaintext secret.
|
||||
// Returned only on credential creation and rotation.
|
||||
type CredentialWithSecret struct {
|
||||
Credential
|
||||
ClientSecret string `json:"clientSecret"`
|
||||
}
|
||||
|
||||
// PaginatedCredentials is a paginated list of credentials.
|
||||
type PaginatedCredentials struct {
|
||||
Data []Credential `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// TokenResponse is the OAuth 2.0 access token response (RFC 6749).
|
||||
type TokenResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
// IntrospectResponse is the token introspection response (RFC 7662).
|
||||
type IntrospectResponse struct {
|
||||
Active bool `json:"active"`
|
||||
Sub *string `json:"sub,omitempty"`
|
||||
ClientID *string `json:"client_id,omitempty"`
|
||||
Scope *string `json:"scope,omitempty"`
|
||||
TokenType *string `json:"token_type,omitempty"`
|
||||
Iat *int64 `json:"iat,omitempty"`
|
||||
Exp *int64 `json:"exp,omitempty"`
|
||||
}
|
||||
|
||||
// AuditEvent is an immutable audit event record.
|
||||
type AuditEvent struct {
|
||||
EventID string `json:"eventId"`
|
||||
AgentID string `json:"agentId"`
|
||||
Action string `json:"action"`
|
||||
Outcome string `json:"outcome"`
|
||||
IPAddress string `json:"ipAddress"`
|
||||
UserAgent string `json:"userAgent"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
// PaginatedAuditEvents is a paginated list of audit events.
|
||||
type PaginatedAuditEvents struct {
|
||||
Data []AuditEvent `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// QueryAuditParams contains optional query parameters for QueryAuditLog.
|
||||
type QueryAuditParams struct {
|
||||
AgentID string
|
||||
Action string
|
||||
Outcome string
|
||||
FromDate string
|
||||
ToDate string
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
Reference in New Issue
Block a user