package api import ( "errors" "time" "atlas9.dev/c/core" "atlas9.dev/c/core/iam" ) const ( Path_BotKeys_Create = "POST /BotKeys_Create" Path_BotKeys_Get = "POST /BotKeys_Get" Path_BotKeys_List = "POST /BotKeys_List" Path_BotKeys_SetExpiration = "POST /BotKeys_SetExpiration" ) // BotKeys_CreateReq is the request for creating an API key. type BotKeys_CreateReq struct { Tenant core.ID Bot core.ID ExpiresAt *time.Time } // BotKeys_CreateRes is the response for creating an API key. type BotKeys_CreateRes struct { ID core.ID Tenant core.ID Bot core.ID // Token is the full bearer credential, ".". It is // returned once at creation and cannot be retrieved again; only a // hash of the secret is stored. Token string CreatedAt time.Time ExpiresAt time.Time } type BotKeys_GetReq struct { ID core.ID Tenant core.ID } type BotKeys_GetRes struct { ID core.ID Tenant core.ID Bot core.ID CreatedAt time.Time ExpiresAt time.Time } type BotKeys_ListReq struct { Tenant core.ID Page core.PageReq } type BotKeys_ListRes struct { Page core.Page[BotKeys_ListItem] } type BotKeys_ListItem struct { ID core.ID Tenant core.ID Bot core.ID CreatedAt time.Time ExpiresAt time.Time } type BotKeys_SetExpirationReq struct { Tenant core.ID ID core.ID ExpiresAt time.Time } type BotKeys_SetExpirationRes struct{} func (r *BotKeys_CreateReq) Prepare() error { if r.Tenant.IsEmpty() { return iam.ErrTenantIDEmpty } return nil } func (r *BotKeys_GetReq) Prepare() error { return nil } func (r *BotKeys_ListReq) Prepare() error { return nil } func (r *BotKeys_SetExpirationReq) Prepare() error { if r.ID.IsEmpty() { return errors.New("ID is required") } return nil }