goapitosdk

package module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 10 Imported by: 0

README

Go Apito SDK

Go Reference Go Report Card

A comprehensive Go SDK for communicating with Apito GraphQL API endpoints. This SDK implements the InjectedDBOperationInterface and provides both type-safe and flexible interfaces for interacting with Apito's backend services.

🚀 Features

  • Complete SDK Implementation: Full implementation of InjectedDBOperationInterface
  • Type-Safe Operations: Generic typed methods for better development experience
  • GraphQL-Based: Native GraphQL communication with Apito backend
  • Authentication Ready: API key and tenant-based authentication
  • Context-Aware: Full context support with timeout and cancellation
  • Comprehensive Error Handling: Detailed error responses and GraphQL error support
  • Plugin-Ready: Perfect for HashiCorp Go plugins and microservices
  • Production Ready: Battle-tested in production environments

📦 Installation

go get github.com/apito-io/go-admin-sdk

When building this repository from a checkout that vendors github.com/apito-io/types via replace ... => ../types, keep the types module cloned as a sibling directory (../types relative to this module root). Remove the replace line after upgrading go.mod to a published types release that includes the matching InternalSDKOperation.GenerateTenantToken signature.

🎯 Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    "time"

    goapitosdk "github.com/apito-io/go-admin-sdk"
)

func main() {
    // Create a new client
    client := goapitosdk.NewClient(goapitosdk.Config{
        BaseURL: "https://api.apito.io/graphql",
        APIKey:  "your-api-key-here",
        Timeout: 30 * time.Second,
    })

    ctx := context.Background()

    // Create a new todo
    todoData := map[string]interface{}{
        "title":       "Learn Apito SDK",
        "description": "Complete the SDK tutorial",
        "status":      "todo",
        "priority":    "high",
    }

    request := &goapitosdk.CreateAndUpdateRequest{
        Model:   "todos",
        Payload: todoData,
    }

    todo, err := client.CreateNewResource(ctx, request)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Created todo: %s\n", todo.ID)
}

⚙️ Configuration

Basic Configuration
client := goapitosdk.NewClient(goapitosdk.Config{
    BaseURL: "https://api.apito.io/graphql",  // Your Apito GraphQL endpoint
    APIKey:  "your-api-key-here",             // X-APITO-KEY header value
    Timeout: 30 * time.Second,                // HTTP client timeout
})
Advanced Configuration
// Custom HTTP client with specific settings
customClient := &http.Client{
    Timeout: 60 * time.Second,
    Transport: &http.Transport{
        MaxIdleConns:        100,
        MaxIdleConnsPerHost: 10,
        IdleConnTimeout:     90 * time.Second,
    },
}

client := goapitosdk.NewClient(goapitosdk.Config{
    BaseURL:    "https://api.apito.io/graphql",
    APIKey:     "your-api-key-here",
    HTTPClient: customClient,
})
Context with Tenant ID
ctx := context.Background()
ctx = context.WithValue(ctx, "tenant_id", "your-tenant-id")

// All operations will now include the tenant ID
results, err := client.SearchResources(ctx, "users", filter, false)

📚 Complete API Reference

🔐 Authentication
Generate Tenant Token

Generate a new tenant token for multi-tenant operations. Arguments match the engine generateTenantToken mutation: tenantID, duration (YYYY-MM-DD; empty string uses one year ahead in UTC), optional role (empty uses engine default admin). Auth uses the client API key, not a legacy token parameter.

tenantToken, err := client.GenerateTenantToken(ctx, "tenant-catalog-id", "2027-12-31", "")
if err != nil {
    log.Fatal(err)
}
fmt.Println("Generated token:", tenantToken)
Pro: tenant catalog users (Apito Pro)

Requires a Pro engine and system GraphQL (/system/graphql) with an admin API key. These operations are project-first (project_id) and return tenant_id in user payloads.

Method Description
LoginTenantUser(ctx, projectID, LoginTenantUserParams) General: Password + Email or Phone. Google code flow: AuthMethod: "google", Code, State; use TenantGoogleOAuthState first for State.
TenantGoogleOAuthState(ctx, projectID) Returns signed OAuth State string for building the Google authorize URL.
SearchTenantUsers(ctx, projectID, limit, offset) List tenant users for a project (each row includes email, phone, tenant_id).
SearchTenantsByDomain(ctx, projectID, domain) Resolve the single SaaS catalog tenant for an exact domain match in the project (tenant null if none).
CreateTenantUser(ctx, projectID, CreateTenantUserParams) Create a local-password tenant user; Password, optional Role, Email, Phone.
UpdateTenantUser(ctx, userID, UpdateTenantUserParams) Update fields using non-nil *string pointers only (email, phone, password, role).
DeleteTenantUser(ctx, userID) Hard-delete a tenant user (returns bool from GraphQL).

On the engine system GraphQL API, createTenant accepts an optional domain argument; when it is set, the engine requires that domain to be unused in the project (otherwise the mutation fails with a clear error). updateTenant validates the same when changing domain. Use executeGraphQL if you need those catalog mutations from the SDK.

// List tenant users by project
list, err := client.SearchTenantUsers(ctx, "project-id", 50, 0)
if err != nil {
    log.Fatal(err)
}
for _, u := range list.Users {
    label := u.Email
    if label == "" {
        label = u.Phone
    }
    if label == "" {
        label = "(no email/phone)"
    }
    fmt.Println(label, u.Role, u.Status)
}

// Login (returns token + user on success)
login, err := client.LoginTenantUser(ctx, "project-id", goapitosdk.LoginTenantUserParams{
    Password: "secret",
    Email:    "user@example.com", // use Phone: "+1555..." when project uses phone identifier
})
if err != nil {
    log.Fatal(err)
}
if login.Token != "" {
    fmt.Println("tenant token:", login.Token)
}

See also: examples/tenant_users/main.go.

📝 Resource Management
Create New Resource

Untyped Creation:

request := &goapitosdk.CreateAndUpdateRequest{
    Model: "users",
    Payload: map[string]interface{}{
        "name":   "John Doe",
        "email":  "john@example.com",
        "active": true,
    },
    Connect: map[string]interface{}{
        "organization_id": "org-123",
    },
}

user, err := client.CreateNewResource(ctx, request)

Type-Safe Creation:

type User struct {
    ID     string `json:"id"`
    Name   string `json:"name"`
    Email  string `json:"email"`
    Active bool   `json:"active"`
}

typedUser, err := goapitosdk.CreateNewResourceTyped[User](client, ctx, request)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Created user: %s (%s)\n", typedUser.Data.Name, typedUser.Data.Email)
Update Resource
updateRequest := &goapitosdk.CreateAndUpdateRequest{
    ID:    "user-123",
    Model: "users",
    Payload: map[string]interface{}{
        "name": "Jane Doe Updated",
    },
    Connect: map[string]interface{}{
        "role_id": "role-456",
    },
    Disconnect: map[string]interface{}{
        "old_role_id": "role-123",
    },
    ForceUpdate: false,
}

updatedUser, err := client.UpdateResource(ctx, updateRequest)
Delete Resource
err := client.DeleteResource(ctx, "users", "user-123")
if err != nil {
    log.Fatal(err)
}
🔍 Search & Retrieval
Search Resources

Basic Search:

filter := map[string]interface{}{
    "limit": 10,
    "page":  1,
    "where": map[string]interface{}{
        "status": "active",
        "role":   "admin",
    },
    "search": "john@example.com",
}

results, err := client.SearchResources(ctx, "users", filter, false)

Type-Safe Search:

typedResults, err := goapitosdk.SearchResourcesTyped[User](client, ctx, "users", filter, false)
if err != nil {
    log.Fatal(err)
}

for _, userDoc := range typedResults.Results {
    fmt.Printf("User: %s (%s)\n", userDoc.Data.Name, userDoc.Data.Email)
}

Advanced Filtering:

advancedFilter := map[string]interface{}{
    "limit":  20,
    "offset": 10,
    "where": map[string]interface{}{
        "created_at": map[string]interface{}{
            "$gte": "2024-01-01T00:00:00Z",
        },
        "status": map[string]interface{}{
            "$in": []string{"active", "pending"},
        },
    },
    "sort": map[string]interface{}{
        "created_at": -1, // Descending order
    },
}

results, err := client.SearchResources(ctx, "users", advancedFilter, false)
Get Single Resource

Untyped Retrieval:

user, err := client.GetSingleResource(ctx, "users", "user-123", false)
if err != nil {
    log.Fatal(err)
}

Type-Safe Retrieval:

typedUser, err := goapitosdk.GetSingleResourceTyped[User](client, ctx, "users", "user-123", false)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("User: %s\n", typedUser.Data.Name)
relationConnection := map[string]interface{}{
    "model": "todos",
    "filter": map[string]interface{}{
        "limit": 10,
        "where": map[string]interface{}{
            "status": "pending",
        },
    },
}

// Get todos related to a user
relatedTodos, err := client.GetRelationDocuments(ctx, "user-123", relationConnection)
if err != nil {
    log.Fatal(err)
}

// Type-safe version
typedTodos, err := goapitosdk.GetRelationDocumentsTyped[Todo](client, ctx, "user-123", relationConnection)
📊 Audit & Debug
Send Audit Log
auditData := goapitosdk.AuditData{
    Resource: "users",
    Action:   "create",
    Author: map[string]interface{}{
        "user_id": "admin-123",
        "name":    "Admin User",
    },
    Data: map[string]interface{}{
        "user_id": "user-456",
        "email":   "newuser@example.com",
    },
    Meta: map[string]interface{}{
        "ip_address": "192.168.1.1",
        "user_agent": "Apito-SDK/1.0",
        "timestamp":  time.Now().Format(time.RFC3339),
    },
}

err := client.SendAuditLog(ctx, auditData)
if err != nil {
    log.Fatal(err)
}
Debug Operations
debugData := map[string]interface{}{
    "operation": "user_creation",
    "duration":  "150ms",
    "success":   true,
}

result, err := client.Debug(ctx, "user_management", debugData)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Debug result: %+v\n", result)

🎯 Complete Todo Example

The SDK includes a comprehensive todo application example that demonstrates all features:

# Set environment variables
export APITO_BASE_URL="https://api.apito.io/graphql"
export APITO_API_KEY="your-api-key"
export APITO_TENANT_ID="your-tenant-id"  # Optional (for tenant-token generation only)
export APITO_AUTH_TOKEN="your-auth-token"  # Optional for token generation

# Run the example
cd examples/basic
go run main.go

The example demonstrates:

  • 🔐 Authentication & tenant token generation
  • 📝 Creating resources (todos, users, categories)
  • 🔍 Searching with both typed and untyped methods
  • 📄 Getting single resources
  • ✏️ Updating resources
  • 🔗 Getting related documents
  • 📊 Audit logging
  • 🐛 Debug functionality
  • 🗑️ Resource cleanup
Pro: tenant catalog users
export APITO_API_KEY="your-api-key"
export APITO_PROJECT_ID="your-project-id"
# Optional: export APITO_TENANT_EMAIL and/or APITO_TENANT_PHONE / APITO_TENANT_PASSWORD to test login
go run ./examples/tenant_users/

Details: examples/tenant_users/README.md.

🏗️ Type System

Defining Custom Types
// Define your data structures
type Todo struct {
    ID          string    `json:"id"`
    Title       string    `json:"title"`
    Description string    `json:"description"`
    Status      string    `json:"status"`
    Priority    string    `json:"priority"`
    DueDate     time.Time `json:"due_date"`
    CreatedAt   time.Time `json:"created_at"`
    UpdatedAt   time.Time `json:"updated_at"`
}

type User struct {
    ID       string `json:"id"`
    Name     string `json:"name"`
    Email    string `json:"email"`
    Role     string `json:"role"`
    Active   bool   `json:"active"`
}
Type-Safe Operations

All operations have type-safe counterparts:

// Type-safe alternatives
GetSingleResourceTyped[T](client, ctx, model, id, singlePageData)
SearchResourcesTyped[T](client, ctx, model, filter, aggregate)
GetRelationDocumentsTyped[T](client, ctx, id, connection)
CreateNewResourceTyped[T](client, ctx, request)
UpdateResourceTyped[T](client, ctx, request)

🔌 Plugin Integration

HashiCorp Go Plugin Usage
// In your plugin
type MyPlugin struct {
    client goapitosdk.InjectedDBOperationInterface
}

func (p *MyPlugin) Initialize(client goapitosdk.InjectedDBOperationInterface) {
    p.client = client
}

func (p *MyPlugin) ProcessData(ctx context.Context) error {
    // Use the client for database operations
    results, err := p.client.SearchResources(ctx, "data", filter, false)
    if err != nil {
        return err
    }

    // Process results...
    return nil
}
Microservice Integration
// In your microservice
type UserService struct {
    apitoClient *goapitosdk.Client
}

func NewUserService(config goapitosdk.Config) *UserService {
    return &UserService{
        apitoClient: goapitosdk.NewClient(config),
    }
}

func (s *UserService) CreateUser(ctx context.Context, userData User) (*User, error) {
    request := &goapitosdk.CreateAndUpdateRequest{
        Model:   "users",
        Payload: structToMap(userData),
    }

    result, err := goapitosdk.CreateNewResourceTyped[User](s.apitoClient, ctx, request)
    if err != nil {
        return nil, err
    }

    return &result.Data, nil
}

🔧 Error Handling

GraphQL Errors
results, err := client.SearchResources(ctx, "users", filter, false)
if err != nil {
    // Check if it's a GraphQL error
    if graphqlErr, ok := err.(*goapitosdk.GraphQLError); ok {
        fmt.Printf("GraphQL Error: %s\n", graphqlErr.Message)
        fmt.Printf("Path: %v\n", graphqlErr.Path)
        fmt.Printf("Extensions: %v\n", graphqlErr.Extensions)
    } else {
        // Handle other errors (HTTP, network, etc.)
        fmt.Printf("Error: %v\n", err)
    }
}
HTTP Errors
// Handle HTTP-level errors
client := goapitosdk.NewClient(goapitosdk.Config{
    BaseURL: "https://api.apito.io/graphql",
    APIKey:  "invalid-key",
    Timeout: 5 * time.Second,
})

_, err := client.SearchResources(ctx, "users", nil, false)
if err != nil {
    if strings.Contains(err.Error(), "HTTP error 401") {
        fmt.Println("Authentication failed - check your API key")
    } else if strings.Contains(err.Error(), "HTTP error 403") {
        fmt.Println("Authorization failed - check your permissions")
    }
}

🧪 Testing

Mock Client
// For testing, you can implement the interface
type MockClient struct{}

func (m *MockClient) SearchResources(ctx context.Context, model string, filter map[string]interface{}, aggregate bool) (*goapitosdk.SearchResult, error) {
    // Return mock data
    return &goapitosdk.SearchResult{
        Results: []*shared.DefaultDocumentStructure{
            {ID: "test-1", Data: map[string]interface{}{"name": "Test User"}},
        },
        Count: 1,
    }, nil
}

// Use in tests
func TestUserService(t *testing.T) {
    service := &UserService{apitoClient: &MockClient{}}
    // Test your service...
}

📈 Performance Tips

Connection Pooling
// Configure HTTP client for better performance
client := &http.Client{
    Transport: &http.Transport{
        MaxIdleConns:          100,
        MaxIdleConnsPerHost:   10,
        IdleConnTimeout:       90 * time.Second,
        TLSHandshakeTimeout:   10 * time.Second,
        ExpectContinueTimeout: 1 * time.Second,
    },
    Timeout: 30 * time.Second,
}

apitoClient := goapitosdk.NewClient(goapitosdk.Config{
    BaseURL:    "https://api.apito.io/graphql",
    APIKey:     "your-api-key",
    HTTPClient: client,
})
Batch Operations
// Instead of multiple individual requests, batch them
var wg sync.WaitGroup
results := make(chan *goapitosdk.SearchResult, 10)

for i := 0; i < 10; i++ {
    wg.Add(1)
    go func(page int) {
        defer wg.Done()
        filter := map[string]interface{}{"page": page, "limit": 100}
        result, err := client.SearchResources(ctx, "users", filter, false)
        if err == nil {
            results <- result
        }
    }(i)
}

go func() {
    wg.Wait()
    close(results)
}()

// Process results as they come in
for result := range results {
    // Process each batch...
}

🚀 Production Deployment

Environment Variables
# Required
APITO_BASE_URL=https://api.apito.io/graphql
APITO_API_KEY=your-production-api-key

# Optional
APITO_TENANT_ID=your-tenant-id
APITO_AUTH_TOKEN=your-auth-token
APITO_TIMEOUT=30s
Docker Configuration
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o app main.go

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/app .
CMD ["./app"]
Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: apito-sdk-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: apito-sdk-app
  template:
    metadata:
      labels:
        app: apito-sdk-app
    spec:
      containers:
        - name: app
          image: your-app:latest
          env:
            - name: APITO_BASE_URL
              value: "https://api.apito.io/graphql"
            - name: APITO_API_KEY
              valueFrom:
                secretKeyRef:
                  name: apito-secrets
                  key: api-key

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup
git clone https://github.com/apito-io/go-admin-sdk.git
cd go-apito-sdk
go mod download
go test ./...

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

Documentation

Index

Examples

Constants

View Source
const Version = "1.7.0"

Version represents the current version of the Go Apito SDK

Variables

This section is empty.

Functions

func CreateNewResourceTyped

func CreateNewResourceTyped[T any](c *Client, ctx context.Context, request *types.CreateAndUpdateRequest) (*types.TypedDocumentStructure[T], error)

CreateNewResourceTyped creates a new resource with typed result

func GetRelationDocumentsTyped

func GetRelationDocumentsTyped[T any](c *Client, ctx context.Context, _id string, connection map[string]interface{}) (*types.TypedSearchResult[T], error)

GetRelationDocumentsTyped retrieves related documents with typed results

func GetSingleResourceTyped

func GetSingleResourceTyped[T any](c *Client, ctx context.Context, model, _id string, singlePageData bool) (*types.TypedDocumentStructure[T], error)

GetSingleResourceTyped retrieves a single resource by model and ID with typed data

Example

ExampleTypedOperations shows how to use the typed operations in documentation

config := Config{
	BaseURL: BaseURL,
	APIKey:  APIKey,
	Timeout: 30 * time.Second,
}
client := NewClient(config)
ctx := context.Background()

// Get a single task with full type safety
task, err := GetSingleResourceTyped[Task](client, ctx, "task", "401fa9f2-b174-42b1-84da-1227be8d8755", false)
if err != nil {
	// Handle error appropriately
	return
}

// Access strongly typed fields
taskName := task.Data.Name
taskProgress := task.Data.Progress

_ = taskName
_ = taskProgress

func GetVersion

func GetVersion() string

GetVersion returns the current version of the SDK

func SearchResourcesTyped

func SearchResourcesTyped[T any](c *Client, ctx context.Context, model string, filter map[string]interface{}, aggregate bool) (*types.TypedSearchResult[T], error)

SearchResourcesTyped searches for resources with typed results

func UpdateResourceTyped

func UpdateResourceTyped[T any](c *Client, ctx context.Context, request *types.CreateAndUpdateRequest) (*types.TypedDocumentStructure[T], error)

UpdateResourceTyped updates a resource with typed result

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents the Apito SDK client

func NewClient

func NewClient(config Config) *Client

NewClient creates a new Apito SDK client

func (*Client) CreateNewResource

func (c *Client) CreateNewResource(ctx context.Context, request *types.CreateAndUpdateRequest) (*types.DefaultDocumentStructure, error)

CreateNewResource creates a new resource in the specified model with the given data and connections

func (*Client) CreateTenantUser

func (c *Client) CreateTenantUser(ctx context.Context, projectID string, params CreateTenantUserParams) (*TenantUser, error)

CreateTenantUser creates a local-password tenant user via system GraphQL mutation createTenantUser.

func (*Client) Debug

func (c *Client) Debug(ctx context.Context, stage string, data ...interface{}) (interface{}, error)

Debug is used to debug the plugin, you can pass data here to debug the plugin

func (*Client) DeleteResource

func (c *Client) DeleteResource(ctx context.Context, model, _id string) error

DeleteResource deletes a resource by model and ID

func (*Client) DeleteTenantUser added in v1.7.0

func (c *Client) DeleteTenantUser(ctx context.Context, userID string) (bool, error)

DeleteTenantUser removes a tenant catalog user by id (system GraphQL deleteTenantUser). Project scope comes from the API key.

func (*Client) GenerateTenantToken

func (c *Client) GenerateTenantToken(ctx context.Context, tenantID, duration, role string) (string, error)

GenerateTenantToken generates a new tenant-scoped API key for the given tenant_id.

Authentication uses the client's Config.APIKey (X-Apito-Key).

duration is the token expiry calendar day (YYYY-MM-DD), matching the engine mutation. If duration is empty, a default of one calendar year ahead in UTC is used.

role is optional; when empty the engine defaults the token role to "admin".

func (*Client) GetRelationDocuments

func (c *Client) GetRelationDocuments(ctx context.Context, _id string, connection map[string]interface{}) (*types.SearchResult, error)

GetRelationDocuments retrieves related documents for the given ID and connection parameters

func (*Client) GetSingleResource

func (c *Client) GetSingleResource(ctx context.Context, model, _id string, singlePageData bool) (*types.DefaultDocumentStructure, error)

GetSingleResource retrieves a single resource by model and ID, with optional single page data

func (*Client) LoginTenantUser

func (c *Client) LoginTenantUser(ctx context.Context, projectID string, params LoginTenantUserParams) (*TenantLoginResponse, error)

LoginTenantUser runs loginTenantUser (password or Google OAuth code flow).

func (*Client) SearchResources

func (c *Client) SearchResources(ctx context.Context, model string, filter map[string]interface{}, aggregate bool) (*types.SearchResult, error)

SearchResources searches for resources in the specified model using the provided filter

func (*Client) SearchTenantUsers

func (c *Client) SearchTenantUsers(ctx context.Context, projectID string, limit, offset int) (*TenantUsersResponse, error)

SearchTenantUsers lists tenant users for a project.

func (*Client) SearchTenantsByDomain

func (c *Client) SearchTenantsByDomain(ctx context.Context, projectID, domain string) (*TenantByDomainResponse, error)

SearchTenantsByDomain returns the single SaaS catalog tenant for an exact domain match in the project, or nil tenant if none.

func (*Client) TenantGoogleOAuthState added in v1.7.0

func (c *Client) TenantGoogleOAuthState(ctx context.Context, projectID string) (*TenantGoogleOAuthStateResponse, error)

TenantGoogleOAuthState fetches signed OAuth state for building the Google authorize URL (tenantGoogleOAuthState query).

func (*Client) UpdateResource

UpdateResource updates an existing resource by model and ID, with optional single page data, data updates, and connection changes

func (*Client) UpdateTenantUser added in v1.7.0

func (c *Client) UpdateTenantUser(ctx context.Context, userID string, params UpdateTenantUserParams) (*TenantUser, error)

UpdateTenantUser updates a tenant catalog user by id (system GraphQL updateTenantUser). Project scope comes from the API key.

type Config

type Config struct {
	BaseURL    string        // Base URL of the Apito GraphQL endpoint
	APIKey     string        // API key for authentication (X-APITO-KEY header)
	Timeout    time.Duration // HTTP client timeout (default: 30 seconds)
	HTTPClient *http.Client  // Custom HTTP client (optional)
}

Config represents the SDK configuration

type CreateTenantUserParams added in v1.7.0

type CreateTenantUserParams struct {
	Password string
	Role     string // optional; engine defaults when empty
	Email    string
	Phone    string
}

CreateTenantUserParams configures createTenantUser. The engine requires an email or phone according to the project's general authentication identifier mode.

type LoginTenantUserParams added in v1.7.0

type LoginTenantUserParams struct {
	Password   string
	Email      string
	Phone      string
	AuthMethod string // optional; "", "general", or "google"
	Code       string // OAuth authorization code (Google)
	State      string // OAuth state (from TenantGoogleOAuthState or callback)
}

LoginTenantUserParams configures login via system GraphQL loginTenantUser. Password path (AuthMethod empty or "general"): set Password plus Email or Phone per project Authentication. Google path (AuthMethod "google"): set Code and State from OAuth callback; optionally use TenantGoogleOAuthState first.

type TenantByDomainResponse

type TenantByDomainResponse struct {
	Tenant *TenantCatalogSearchRow `json:"tenant"`
}

TenantByDomainResponse is returned by searchTenantsByDomain (at most one match per project).

type TenantCatalogSearchRow

type TenantCatalogSearchRow struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
	Domain string `json:"domain"`
	Data   string `json:"data"`
}

TenantCatalogSearchRow is one catalog tenant row from searchTenantsByDomain.

type TenantGoogleOAuthStateResponse added in v1.7.0

type TenantGoogleOAuthStateResponse struct {
	State string
}

TenantGoogleOAuthStateResponse is returned by tenantGoogleOAuthState.

type TenantLoginResponse

type TenantLoginResponse struct {
	Token string      `json:"token"`
	User  *TenantUser `json:"user"`
}

TenantLoginResponse is returned by loginTenantUser (general or Google code flow).

type TenantUser

type TenantUser struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Phone     string `json:"phone"`
	Role      string `json:"role"`
	TenantID  string `json:"tenant_id"`
	Provider  string `json:"provider"`
	Status    string `json:"status"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

TenantUser is a row from the engine system control plane (pro_tenant_users).

type TenantUsersResponse

type TenantUsersResponse struct {
	Users []*TenantUser `json:"users"`
	Count int           `json:"count"`
}

TenantUsersResponse is returned by searchTenantUsers.

type UpdateTenantUserParams added in v1.7.0

type UpdateTenantUserParams struct {
	Email    *string
	Phone    *string
	Password *string
	Role     *string
}

UpdateTenantUserParams lists optional fields for updateTenantUser. Nil pointers are omitted from the mutation.

Directories

Path Synopsis
tenant_users command
Tenant catalog users example (Apito Pro).
Tenant catalog users example (Apito Pro).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL