Documentation
¶
Index ¶
- Constants
- func CreateNewResourceTyped[T any](c *Client, ctx context.Context, request *types.CreateAndUpdateRequest) (*types.TypedDocumentStructure[T], error)
- func GetRelationDocumentsTyped[T any](c *Client, ctx context.Context, _id string, connection map[string]interface{}) (*types.TypedSearchResult[T], error)
- func GetSingleResourceTyped[T any](c *Client, ctx context.Context, model, _id string, singlePageData bool) (*types.TypedDocumentStructure[T], error)
- func GetVersion() string
- func SearchResourcesTyped[T any](c *Client, ctx context.Context, model string, filter map[string]interface{}, ...) (*types.TypedSearchResult[T], error)
- func UpdateResourceTyped[T any](c *Client, ctx context.Context, request *types.CreateAndUpdateRequest) (*types.TypedDocumentStructure[T], error)
- type Client
- func (c *Client) CreateNewResource(ctx context.Context, request *types.CreateAndUpdateRequest) (*types.DefaultDocumentStructure, error)
- func (c *Client) CreateTenantUser(ctx context.Context, projectID string, params CreateTenantUserParams) (*TenantUser, error)
- func (c *Client) Debug(ctx context.Context, stage string, data ...interface{}) (interface{}, error)
- func (c *Client) DeleteResource(ctx context.Context, model, _id string) error
- func (c *Client) DeleteTenantUser(ctx context.Context, userID string) (bool, error)
- func (c *Client) GenerateTenantToken(ctx context.Context, tenantID, duration, role string) (string, error)
- func (c *Client) GetRelationDocuments(ctx context.Context, _id string, connection map[string]interface{}) (*types.SearchResult, error)
- func (c *Client) GetSingleResource(ctx context.Context, model, _id string, singlePageData bool) (*types.DefaultDocumentStructure, error)
- func (c *Client) LoginTenantUser(ctx context.Context, projectID string, params LoginTenantUserParams) (*TenantLoginResponse, error)
- func (c *Client) SearchResources(ctx context.Context, model string, filter map[string]interface{}, ...) (*types.SearchResult, error)
- func (c *Client) SearchTenantUsers(ctx context.Context, projectID string, limit, offset int) (*TenantUsersResponse, error)
- func (c *Client) SearchTenantsByDomain(ctx context.Context, projectID, domain string) (*TenantByDomainResponse, error)
- func (c *Client) TenantGoogleOAuthState(ctx context.Context, projectID string) (*TenantGoogleOAuthStateResponse, error)
- func (c *Client) UpdateResource(ctx context.Context, request *types.CreateAndUpdateRequest) (*types.DefaultDocumentStructure, error)
- func (c *Client) UpdateTenantUser(ctx context.Context, userID string, params UpdateTenantUserParams) (*TenantUser, error)
- type Config
- type CreateTenantUserParams
- type LoginTenantUserParams
- type TenantByDomainResponse
- type TenantCatalogSearchRow
- type TenantGoogleOAuthStateResponse
- type TenantLoginResponse
- type TenantUser
- type TenantUsersResponse
- type UpdateTenantUserParams
Examples ¶
Constants ¶
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 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 (*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 ¶
Debug is used to debug the plugin, you can pass data here to debug the plugin
func (*Client) DeleteResource ¶
DeleteResource deletes a resource by model and ID
func (*Client) DeleteTenantUser ¶ added in v1.7.0
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 ¶
func (c *Client) UpdateResource(ctx context.Context, request *types.CreateAndUpdateRequest) (*types.DefaultDocumentStructure, error)
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
tenant_users
command
Tenant catalog users example (Apito Pro).
|
Tenant catalog users example (Apito Pro). |