Documentation
¶
Overview ¶
theauthapi/client.go
Package theauthapi provides a Go client for accessing the TheAuthAPI.
Usage:
client := theauthapi.NewClient("YOUR_ACCESS_KEY")
// Use the client to make API calls
isValid, err := client.ApiKeys.IsValidKey(ctx, "EXAMPLE_API_KEY")
theauthapi/errors.go
Index ¶
- Constants
- type APIError
- type Account
- type AccountsService
- type ApiKey
- type ApiKeyFilter
- type ApiKeyInput
- type ApiKeysService
- type AuthBaseEntity
- type AuthedEntityType
- type Client
- type ClientOption
- type CreateProjectInput
- type Environment
- type Project
- type ProjectsService
- type RateLimitConfiguration
- type Response
- type UpdateApiKeyInput
- type UpdateProjectInput
Constants ¶
const Version = "0.1.2"
Version is the current version of the SDK
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError represents a generic API error
func NewAPIError ¶
NewAPIError creates a new APIError
func (*APIError) IsNotFound ¶
IsNotFound checks if the error is a 404 Not Found error
func (*APIError) IsUnauthorized ¶
IsUnauthorized checks if the error is a 401 Unauthorized error
type Account ¶
type Account struct {
AuthBaseEntity
ID string `json:"id"`
Name string `json:"name"`
}
Account represents an account entity
type AccountsService ¶
type AccountsService struct {
// contains filtered or unexported fields
}
type ApiKey ¶
type ApiKey struct {
Key string `json:"key"`
Name string `json:"name"`
CustomMetaData map[string]interface{} `json:"customMetaData"`
CustomAccountID string `json:"customAccountId"`
CustomUserID string `json:"customUserId"`
Env Environment `json:"env"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
IsActive bool `json:"isActive"`
RateLimitConfigs RateLimitConfiguration `json:"rateLimitConfigs"`
Expiry time.Time `json:"expiry"`
}
ApiKey represents an API key and its associated data
type ApiKeyFilter ¶
type ApiKeyFilter struct {
ProjectID *string `json:"projectId,omitempty"`
Name *string `json:"name,omitempty"`
CustomAccountID *string `json:"customAccountId,omitempty"`
CustomUserID *string `json:"customUserId,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
ApiKeyFilter represents filtering options for API keys
type ApiKeyInput ¶
type ApiKeyInput struct {
Name string `json:"name"`
ProjectID *string `json:"projectId,omitempty"`
Key *string `json:"key,omitempty"`
CustomMetaData map[string]interface{} `json:"customMetaData,omitempty"`
CustomAccountID *string `json:"customAccountId,omitempty"`
CustomUserID *string `json:"customUserId,omitempty"`
RateLimitConfigs *RateLimitConfiguration `json:"rateLimitConfigs,omitempty"`
Expiry *time.Time `json:"expiry,omitempty"`
}
ApiKeyInput represents the input for creating a new API key
type ApiKeysService ¶
type ApiKeysService struct {
// contains filtered or unexported fields
}
func (*ApiKeysService) IsValidKey ¶
type AuthBaseEntity ¶
type AuthBaseEntity struct {
IsActive bool `json:"isActive"`
CreatedBy string `json:"createdBy"`
CreatedByType *AuthedEntityType `json:"createdByType,omitempty"`
CreatedIn string `json:"createdIn"`
LastChangedBy string `json:"lastChangedBy"`
LastChangedByType *AuthedEntityType `json:"lastChangedByType,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
CreatedAt time.Time `json:"createdAt"`
}
AuthBaseEntity contains common fields for authenticated entities
type AuthedEntityType ¶
type AuthedEntityType string
AuthedEntityType represents the type of authenticated entity
const ( AuthedEntityTypeUser AuthedEntityType = "USER" AuthedEntityTypeAccessKey AuthedEntityType = "ACCESS_KEY" )
type Client ¶
type Client struct {
AccessToken string
BaseURL string
HTTPClient *http.Client
ApiKeys *ApiKeysService
Projects *ProjectsService
Accounts *AccountsService
}
Client is the main TheAuthAPI client
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new TheAuthAPI client with optional configurations
type ClientOption ¶
type ClientOption func(*Client)
ClientOption allows customizing the client
func WithAccessToken ¶
func WithAccessToken(accessToken string) ClientOption
WithAccessToken sets the access token for the client
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL allows overriding the base API URL (useful for testing)
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient allows providing a custom HTTP client
type CreateProjectInput ¶
type CreateProjectInput struct {
Name string `json:"name"`
AccountID string `json:"accountId"`
Env Environment `json:"env"`
}
CreateProjectInput represents the input for creating a new project
type Environment ¶
type Environment string
Environment represents the environment type
const ( EnvironmentLive Environment = "live" EnvironmentTest Environment = "test" )
type Project ¶
type Project struct {
AuthBaseEntity
ID string `json:"id"`
Name string `json:"name"`
AccountID string `json:"accountId"`
Env Environment `json:"env"`
}
Project represents a project entity
type ProjectsService ¶
type ProjectsService struct {
// contains filtered or unexported fields
}
type RateLimitConfiguration ¶
type RateLimitConfiguration struct {
RateLimit int `json:"rateLimit"`
RateLimitTtl int `json:"rateLimitTtl"`
}
RateLimitConfiguration defines rate limiting settings
type UpdateApiKeyInput ¶
type UpdateApiKeyInput struct {
Name string `json:"name"`
Key *string `json:"key,omitempty"`
CustomMetaData map[string]interface{} `json:"customMetaData,omitempty"`
CustomAccountID *string `json:"customAccountId,omitempty"`
CustomUserID *string `json:"customUserId,omitempty"`
Expiry *time.Time `json:"expiry,omitempty"`
RateLimitConfigs *RateLimitConfiguration `json:"rateLimitConfigs,omitempty"`
}
UpdateApiKeyInput represents the input for updating an API key
type UpdateProjectInput ¶
type UpdateProjectInput struct {
Name string `json:"name"`
}
UpdateProjectInput represents the input for updating a project