api

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for making API calls

func NewClient

func NewClient(baseURL string, timeout time.Duration) *Client

NewClient creates a new API client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, headers map[string]string) (*Response, error)

Delete makes a DELETE request

func (*Client) Do

func (c *Client) Do(ctx context.Context, req Request) (*Response, error)

Do makes an API request

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query map[string]string, headers map[string]string) (*Response, error)

Get makes a GET request

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}, headers map[string]string) (*Response, error)

Post makes a POST request

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body interface{}, headers map[string]string) (*Response, error)

Put makes a PUT request

func (*Client) SetHeader

func (c *Client) SetHeader(key, value string)

SetHeader sets a header for all requests

func (*Client) SetHeaders

func (c *Client) SetHeaders(headers map[string]string)

SetHeaders sets multiple headers for all requests

type Request

type Request struct {
	Method  string
	Path    string
	Body    interface{}
	Headers map[string]string
	Query   map[string]string
}

Request represents an API request

type Response

type Response struct {
	StatusCode int
	Body       []byte
	Headers    http.Header
}

Response represents an API response

type TaskAPI

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

TaskAPI provides a way to execute tasks over an API

func NewTaskAPI

func NewTaskAPI(client *Client) *TaskAPI

NewTaskAPI creates a new task API with the given client

func (*TaskAPI) ExecuteTask

func (a *TaskAPI) ExecuteTask(ctx context.Context, taskID string) error

ExecuteTask executes a task via the API

func (*TaskAPI) GetTaskStatus

func (a *TaskAPI) GetTaskStatus(ctx context.Context, taskID string) (core.Status, error)

GetTaskStatus gets the status of a task

func (*TaskAPI) RegisterWithExecutor

func (a *TaskAPI) RegisterWithExecutor(exec *executor.TaskExecutor, taskName string, request Request)

RegisterWithExecutor registers API tasks with an executor

func (*TaskAPI) Task

func (a *TaskAPI) Task(request Request) executor.TaskFunc

Task returns a TaskFunc that executes a task via API

Jump to

Keyboard shortcuts

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