Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) CreateJWT(ttl time.Duration, claims any) (string, error)
- func (c *Client) GetHistory(ctx context.Context, jwt, workflowID, historyID string) (*GetHistoryResponse, error)
- func (c *Client) GetRecentHistory(ctx context.Context, workflowID string, maxDays, maxResults int, ...) (*GetRecentHistoryResponse, error)
- func (c *Client) LockWorkflows(ctx context.Context, ids []string, comment string) (*LockWorkflowsResponse, error)
- func (c *Client) RunWorkflow(ctx context.Context, jwt, encodedWorkflowID string, queue bool, ...) (*RunWorkflowResponse, error)
- func (c *Client) RunWorkflowV2Signed(ctx context.Context, encodedWorkflowID string, queue bool, params []Parameter, ...) (*RunWorkflowResponse, error)
- func (c *Client) SearchWorkflows(ctx context.Context, filters *SearchFilters, view string, maxResults int, ...) (*SearchWorkflowsResponse, error)
- func (c *Client) SignUrls(ctx context.Context, gcsURIs []string, expirationSec int64) (*SignUrlsResponse, error)
- func (c *Client) UnlockWorkflows(ctx context.Context, ids []string, comment string) (*LockWorkflowsResponse, error)
- type Error
- type ErrorDetail
- type GetHistoryBody
- type GetHistoryRequest
- type GetHistoryResponse
- type GetRecentHistoryRequest
- type GetRecentHistoryResponse
- type History
- type LockUnlockBody
- type LockWorkflowsRequest
- type LockWorkflowsResponse
- type Option
- type Parameter
- type RecentHistory
- type RunWorkflow
- type RunWorkflowRequest
- type RunWorkflowResponse
- type RunWorkflowResult
- type SearchFilters
- type SearchWorkflowsRequest
- type SearchWorkflowsResponse
- type SignUrlsBody
- type SignUrlsRequest
- type SignUrlsResponse
- type Workflow
Constants ¶
const ( CommandRunWorkflowV2 = "713aa58d" // Remote Workflow Execution v2 CommandGetHistory = "a83270b7" // Get Workflow History CommandSignUrls = "4ab037fb" // Generate Signed URLs CommandLockWorkflows = "6f570e7l" // Lock workflows CommandUnlockWorkflows = "6f570e7u" // Unlock workflows CommandSearchWorkflows = "searchWorkflows" CommandGetRecentHistory = "getRecentHistory" )
Command constants for Magnus Remote API.
const DefaultEndpoint = "http://magnus.viantinc.com/remote"
DefaultEndpoint is the default Magnus Remote API endpoint.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Endpoint is the Magnus remote URL, for example DefaultEndpoint.
Endpoint string
// HTTPClient is the underlying HTTP client. If nil, http.DefaultClient is used.
HTTPClient *http.Client
// contains filtered or unexported fields
}
Client is a thin HTTP client for the Magnus Remote API.
func NewClient ¶
NewClient (compat) creates a new Magnus client with explicit endpoint and http client. It delegates to New with appropriate options.
func (*Client) GetHistory ¶
func (c *Client) GetHistory(ctx context.Context, jwt, workflowID, historyID string) (*GetHistoryResponse, error)
GetHistory retrieves a single workflow history record by workflowId and historyId.
func (*Client) GetRecentHistory ¶
func (c *Client) GetRecentHistory(ctx context.Context, workflowID string, maxDays, maxResults int, pageToken string) (*GetRecentHistoryResponse, error)
GetRecentHistory returns recent execution history for a workflow.
func (*Client) LockWorkflows ¶
func (c *Client) LockWorkflows(ctx context.Context, ids []string, comment string) (*LockWorkflowsResponse, error)
LockWorkflows locks the given workflows.
func (*Client) RunWorkflow ¶
func (c *Client) RunWorkflow(ctx context.Context, jwt, encodedWorkflowID string, queue bool, params []Parameter, billingProject string, cascadeBilling bool) (*RunWorkflowResponse, error)
RunWorkflow executes a Magnus workflow asynchronously using Remote Workflow Execution v2.
func (*Client) RunWorkflowV2Signed ¶
func (c *Client) RunWorkflowV2Signed(ctx context.Context, encodedWorkflowID string, queue bool, params []Parameter, billingProject string, cascadeBilling bool, ttl time.Duration, claims any) (*RunWorkflowResponse, error)
RunWorkflowV2Signed mints a JWT using the client's signer and runs the workflow.
func (*Client) SearchWorkflows ¶
func (c *Client) SearchWorkflows(ctx context.Context, filters *SearchFilters, view string, maxResults int, pageToken string) (*SearchWorkflowsResponse, error)
SearchWorkflows searches for workflows matching provided filters.
func (*Client) SignUrls ¶
func (c *Client) SignUrls(ctx context.Context, gcsURIs []string, expirationSec int64) (*SignUrlsResponse, error)
SignUrls generates signed URLs for the given GCS URIs.
func (*Client) UnlockWorkflows ¶
func (c *Client) UnlockWorkflows(ctx context.Context, ids []string, comment string) (*LockWorkflowsResponse, error)
UnlockWorkflows unlocks the given workflows.
type ErrorDetail ¶
ErrorDetail describes an error returned by Magnus in the response body.
type GetHistoryBody ¶
type GetHistoryBody struct {
WorkflowID string `json:"workflowId"`
HistoryID string `json:"historyId"`
}
GetHistoryBody is configuration.getHistory.
type GetHistoryRequest ¶
type GetHistoryRequest struct {
Jwt string `json:"jwt,omitempty"`
C string `json:"c"`
Configuration getHistoryConfig `json:"configuration"`
}
GetHistoryRequest is the request payload for the Get Workflow History API.
type GetHistoryResponse ¶
type GetHistoryResponse struct {
Result *struct {
History History `json:"history"`
} `json:"result,omitempty"`
// contains filtered or unexported fields
}
GetHistoryResponse is the response for Get Workflow History.
type GetRecentHistoryRequest ¶
type GetRecentHistoryRequest struct {
Jwt string `json:"jwt,omitempty"`
C string `json:"c"`
Configuration recentHistoryConfig `json:"configuration"`
}
GetRecentHistoryRequest is the request payload for the Get Recent History API.
type GetRecentHistoryResponse ¶
type GetRecentHistoryResponse struct {
Result *struct {
History []RecentHistory `json:"history"`
NextPageToken string `json:"nextPageToken,omitempty"`
} `json:"result,omitempty"`
// contains filtered or unexported fields
}
GetRecentHistoryResponse is the response for Get Recent History.
type History ¶
type History struct {
HistoryID string `json:"historyId"`
WorkflowID string `json:"workflowId"`
RunReason string `json:"runReason"`
WorkflowOwners string `json:"workflowOwners"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
Status struct {
State string `json:"state"`
Error *ErrorDetail `json:"error,omitempty"`
} `json:"status"`
}
History represents a workflow history record.
type LockUnlockBody ¶
type LockUnlockBody struct {
WorkflowIDs []string `json:"workflowIds"`
Comment string `json:"comment,omitempty"`
}
LockUnlockBody represents configuration.lockWorkflows or configuration.unlockWorkflows.
type LockWorkflowsRequest ¶
type LockWorkflowsRequest struct {
Jwt string `json:"jwt,omitempty"`
C string `json:"c"`
Configuration lockUnlockConfig `json:"configuration"`
}
LockWorkflowsRequest is the request for locking or unlocking workflows.
type LockWorkflowsResponse ¶
type LockWorkflowsResponse struct {
Result *struct {
UpdatedWorkflows []string `json:"updatedWorkflows"`
Errors []string `json:"errors"`
} `json:"result,omitempty"`
// contains filtered or unexported fields
}
LockWorkflowsResponse is the response from lock/unlock workflows API.
type Option ¶
Option configures a Client.
func WithEndpoint ¶
WithEndpoint sets the remote endpoint.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithJWTDefaults ¶
WithJWTDefaults sets default TTL and claims used when a JWT is not explicitly provided.
func WithScyRSA ¶
WithScyRSA initializes an RSA signer from a scy resource; only once per client.
func WithSigner ¶
WithSigner assigns a pre-initialized JWT signer; only once per client.
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Value interface{} `json:"value"`
}
Parameter represents a single workflow parameter override.
type RecentHistory ¶
type RecentHistory struct {
HistoryID string `json:"historyId"`
WorkflowID string `json:"workflowId"`
Owner string `json:"owner"`
RunBy string `json:"runBy"`
RunReason string `json:"runReason"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime,omitempty"`
StatusState string `json:"statusState"`
StatusError string `json:"statusError,omitempty"`
}
RecentHistory is a single history entry from Get Recent History.
type RunWorkflow ¶
type RunWorkflow struct {
// L is the encoded workflow ID (required).
L string `json:"l"`
// Queue controls Fair Scheduler queuing. Default is false.
Queue bool `json:"queue,omitempty"`
// Parameters is the list of parameter overrides.
Parameters []Parameter `json:"parameters,omitempty"`
// BillingProject is the billing project for execution (optional).
BillingProject string `json:"billingProject,omitempty"`
// CascadeBillingProject cascades the billing project to child workflows.
CascadeBillingProject bool `json:"cascadeBillingProject,omitempty"`
}
RunWorkflow describes configuration.runWorkflow for Remote Workflow Execution v2.
type RunWorkflowRequest ¶
type RunWorkflowRequest struct {
// Jwt is required for direct HTTP calls.
Jwt string `json:"jwt,omitempty"`
// C is the command code; should be CommandRunWorkflowV2.
C string `json:"c"`
// Configuration holds the run workflow configuration.
Configuration runWorkflowConfig `json:"configuration"`
}
RunWorkflowRequest is the full Remote Workflow Execution v2 request.
type RunWorkflowResponse ¶
type RunWorkflowResponse struct {
Result *RunWorkflowResult `json:"result,omitempty"`
// contains filtered or unexported fields
}
RunWorkflowResponse is the typed response for run workflow v2.
type RunWorkflowResult ¶
type RunWorkflowResult struct {
WorkflowID string `json:"workflowId"`
HistoryID string `json:"historyId"`
}
RunWorkflowResult holds workflowId and historyId on success.
type SearchFilters ¶
type SearchFilters struct {
UserID string `json:"userId,omitempty"`
UserRoles []string `json:"userRoles,omitempty"`
OrgID string `json:"orgId,omitempty"`
IsModificationLocked *bool `json:"isModificationLocked,omitempty"`
IsEnabled *bool `json:"isEnabled,omitempty"`
IsCritical *bool `json:"isCritical,omitempty"`
IsPublic *bool `json:"isPublic,omitempty"`
IsArchived *bool `json:"isArchived,omitempty"`
IsDraft *bool `json:"isDraft,omitempty"`
Labels []map[string]string `json:"labels,omitempty"`
Content string `json:"content,omitempty"`
}
SearchFilters represents configuration.filters.
type SearchWorkflowsRequest ¶
type SearchWorkflowsRequest struct {
Jwt string `json:"jwt,omitempty"`
C string `json:"c"`
Configuration searchConfig `json:"configuration"`
}
SearchWorkflowsRequest is the request payload for the Search Workflows API.
type SearchWorkflowsResponse ¶
type SearchWorkflowsResponse struct {
Result *struct {
Workflows []Workflow `json:"workflows"`
NextPageToken string `json:"nextPageToken,omitempty"`
} `json:"result,omitempty"`
// contains filtered or unexported fields
}
SearchWorkflowsResponse is the response for Search Workflows.
type SignUrlsBody ¶
type SignUrlsBody struct {
GcsURIs []string `json:"gcsUris"`
ExpirationSec int64 `json:"expirationSec"`
}
SignUrlsBody is configuration.signUrls.
type SignUrlsRequest ¶
type SignUrlsRequest struct {
Jwt string `json:"jwt,omitempty"`
C string `json:"c"`
Configuration signUrlsConfig `json:"configuration"`
}
SignUrlsRequest is the request for the Sign URLs API.
type SignUrlsResponse ¶
type SignUrlsResponse struct {
Result *struct {
SignedUrls []string `json:"signedUrls"`
} `json:"result,omitempty"`
// contains filtered or unexported fields
}
SignUrlsResponse is the response for Sign URLs.
type Workflow ¶
type Workflow struct {
WorkflowID string `json:"workflowId"`
Owner string `json:"owner"`
Delegates []string `json:"delegates,omitempty"`
LifetimeStartDate string `json:"lifetimeStartDate,omitempty"`
LifetimeEndDate string `json:"lifetimeEndDate,omitempty"`
Schedule string `json:"schedule,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
IsEnabled bool `json:"isEnabled"`
IsPublic bool `json:"isPublic"`
IsCritical bool `json:"isCritical"`
IsRunByOwnerAlways bool `json:"isRunByOwnerAlways"`
IsModificationLocked bool `json:"isModificationLocked"`
IsDraft bool `json:"isDraft"`
IsArchived bool `json:"isArchived"`
LastRunAt int64 `json:"lastRunAt,omitempty"`
NextRunAt int64 `json:"nextRunAt,omitempty"`
Labels []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"labels,omitempty"`
CreatedBy string `json:"createdBy"`
CreatedTime int64 `json:"createdTime"`
ModifiedBy string `json:"modifiedBy"`
ModifiedTime int64 `json:"modifiedTime"`
Comment string `json:"comment,omitempty"`
}
Workflow is a single workflow entry returned by Search Workflows.