request

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNon200Status = errors.New("error response from API")
	ErrNotFound     = errors.New("HTTP Status 404")
)
View Source
var ApiVersion = "v1" //nolint:gochecknoglobals

Functions

func FetchProviderCatalog added in v1.2.0

func FetchProviderCatalog(ctx context.Context, target any) error

FetchProviderCatalog fetches the live ("dynamic") provider catalog from the Ampersand API and unmarshals it into target. The catalog changes several times a day, so callers should prefer it over any catalog compiled into a dependency. The endpoint is public (no auth) and not project-scoped, so this works without a configured project or an active login session. target is typically a *providers.CatalogType from the connectors package.

Types

type APIClient

type APIClient struct {
	Root      string
	ProjectId string
	APIKey    *string
	Client    *Client
}

func NewAPIClient

func NewAPIClient(projectId string, key *string) *APIClient

func (*APIClient) BatchUpsertIntegrations

func (c *APIClient) BatchUpsertIntegrations(
	ctx context.Context, reqParams BatchUpsertIntegrationsParams,
) ([]IntegrationName, error)

func (*APIClient) CreateDestination added in v0.1.16

func (c *APIClient) CreateDestination(ctx context.Context, dest *Destination) (*Destination, error)

func (*APIClient) DeleteInstallation added in v0.1.11

func (c *APIClient) DeleteInstallation(ctx context.Context, integrationId string, installationId string) error

func (*APIClient) DeleteIntegration added in v0.1.7

func (c *APIClient) DeleteIntegration(ctx context.Context, integrationId string) error

func (*APIClient) GetCatalog added in v1.0.4

func (c *APIClient) GetCatalog(ctx context.Context) (openapi.CatalogType, error)

func (*APIClient) GetDestination added in v0.1.16

func (c *APIClient) GetDestination(ctx context.Context, id string) (*Destination, error)

func (*APIClient) GetMyInfo added in v0.1.13

func (c *APIClient) GetMyInfo(ctx context.Context) (map[string]any, error)

func (*APIClient) GetPreSignedUploadURL added in v0.1.3

func (c *APIClient) GetPreSignedUploadURL(ctx context.Context, md5 string) (SignedURL, error)

func (*APIClient) ListConnections added in v0.1.17

func (c *APIClient) ListConnections(ctx context.Context) ([]*Connection, error)

func (*APIClient) ListDestinations added in v0.1.16

func (c *APIClient) ListDestinations(ctx context.Context) ([]*Destination, error)

func (*APIClient) ListInstallations added in v0.1.14

func (c *APIClient) ListInstallations(ctx context.Context, integrationId string) ([]*Installation, error)

func (*APIClient) ListIntegrations added in v0.1.14

func (c *APIClient) ListIntegrations(ctx context.Context) ([]*Integration, error)

func (*APIClient) ListProjects added in v0.1.15

func (c *APIClient) ListProjects(ctx context.Context) ([]*Project, error)

func (*APIClient) ListProviderApps added in v0.1.17

func (c *APIClient) ListProviderApps(ctx context.Context) ([]*ProviderApp, error)

func (*APIClient) PatchDestination added in v0.1.16

func (c *APIClient) PatchDestination(ctx context.Context, id string, patch *PatchDestination) (*Destination, error)

type BatchUpsertIntegrationsParams

type BatchUpsertIntegrationsParams struct {
	SourceZipURL string `json:"sourceZipUrl"`

	// Defaults to false. This flag controls whether to perform destructive actions when deploying integrations, like
	// pausing all read actions for an object that was removed in the latest revision.
	Destructive bool `json:"-"` // Not sent in body, used as query param
}

type Client added in v0.1.13

type Client struct {
	Client         *http.Client
	DefaultHeaders []Header
}

func NewRequestClient

func NewRequestClient() *Client

func (*Client) Delete added in v0.1.13

func (c *Client) Delete(ctx context.Context,
	url string, headers ...Header,
) (*http.Response, error)

Delete makes a Delete request to the desired URL for plain text requests.

func (*Client) Get added in v0.1.13

func (c *Client) Get(ctx context.Context,
	url string, result any, headers ...Header,
) (*http.Response, error)

Get makes a GET request to the desired URL, and unmarshalls the response body into `result`.

func (*Client) Patch added in v0.1.16

func (c *Client) Patch(ctx context.Context,
	url string, reqBody any, result any, headers ...Header,
) (*http.Response, error)

Patch makes a Patch request to the desired URL, and unmarshalls the response body into `result`.

func (*Client) Post added in v0.1.13

func (c *Client) Post(ctx context.Context,
	url string, reqBody any, result any, headers ...Header,
) (*http.Response, error)

Post makes a POST request to the desired URL, and unmarshalls the response body into `result`.

func (*Client) Put added in v0.1.13

func (c *Client) Put(ctx context.Context,
	url string, reqBody any, result any, headers ...Header,
) (*http.Response, error)

Put makes a PUT request to the desired URL, and unmarshalls the response body into `result`.

type Config added in v0.1.14

type Config struct {
	Id             string    `json:"id"`
	RevisionId     string    `json:"revisionId"`
	CreatedBy      string    `json:"createdBy"`
	Content        any       `json:"content"`
	InstallationId string    `json:"installationId"`
	CreateTime     time.Time `json:"createTime"`
}

type Connection added in v0.1.14

type Connection struct {
	Id                   string             `json:"id"`
	ProjectId            string             `json:"projectId"`
	ProviderApp          *ProviderApp       `json:"providerApp,omitempty"`
	Group                *Group             `json:"group"`
	Consumer             *Consumer          `json:"consumer"`
	ProviderWorkspaceRef string             `json:"providerWorkspaceRef"`
	ProviderConsumerRef  string             `json:"providerConsumerRef"`
	CreateTime           time.Time          `json:"createTime"`
	UpdateTime           time.Time          `json:"updateTime"`
	Scopes               []string           `json:"scopes"`
	Status               string             `json:"status"`
	CatalogVars          *map[string]string `json:"catalogVars,omitempty"`
}

type Consumer added in v0.1.14

type Consumer struct {
	ConsumerRef  string    `json:"consumerRef"`
	ConsumerName string    `json:"consumerName"`
	ProjectId    string    `json:"projectId"`
	CreateTime   time.Time `json:"createTime"`
	UpdateTime   time.Time `json:"updateTime"`
}

type Destination added in v0.1.16

type Destination struct {
	Id         string           `json:"id"`
	ProjectId  string           `json:"projectId"`
	Name       string           `json:"name"`
	Type       string           `json:"type"`
	Metadata   *WebhookMetadata `json:"metadata"`
	CreateTime time.Time        `json:"createTime"`
	UpdateTime time.Time        `json:"updateTime"`
}

type Group added in v0.1.14

type Group struct {
	GroupRef   string    `json:"groupRef"`
	GroupName  string    `json:"groupName"`
	ProjectId  string    `json:"projectId"`
	CreateTime time.Time `json:"createTime"`
	UpdateTime time.Time `json:"updateTime"`
}
type Header struct {
	Key   string
	Value string
}

Header is a key/value pair that can be added to a request.

type InputValidationIssue added in v0.1.13

type InputValidationIssue struct {
	In           string         `json:"in,omitempty"`
	Name         string         `json:"name,omitempty"`
	Value        any            `json:"value,omitempty"`
	Detail       string         `json:"detail,omitempty"`
	Href         string         `json:"href,omitempty"`
	Instance     string         `json:"instance,omitempty"`
	Status       int32          `json:"status,omitempty"`
	Title        string         `json:"title,omitempty"`
	Type         string         `json:"type,omitempty"`
	Subsystem    string         `json:"subsystem,omitempty"`
	Time         string         `json:"time,omitempty"`
	RequestID    string         `json:"requestId,omitempty"`
	Causes       []string       `json:"causes,omitempty"`
	Remedy       string         `json:"remedy,omitempty"`
	SupportEmail string         `json:"supportEmail,omitempty"`
	SupportPhone string         `json:"supportPhone,omitempty"`
	SupportURL   string         `json:"supportUrl,omitempty"`
	Retryable    *bool          `json:"retryable,omitempty"`
	RetryAfter   string         `json:"retryAfter,omitempty"`
	Context      map[string]any `json:"context,omitempty"`
}

type Installation added in v0.1.14

type Installation struct {
	Id            string      `json:"id"`
	ProjectId     string      `json:"projectId"`
	IntegrationId string      `json:"integrationId"`
	GroupRef      string      `json:"groupRef,omitempty"`
	Group         *Group      `json:"group"`
	ConnectionId  string      `json:"connectionId,omitempty"`
	Connection    *Connection `json:"connection"`
	CreatedBy     string      `json:"createdBy"`
	Config        *Config     `json:"config"`
	CreateTime    time.Time   `json:"createTime"`
	HealthStatus  string      `json:"healthStatus"`
}

type Integration

type Integration struct {
	Id             string    `json:"id"`
	Provider       string    `json:"provider"`
	ProjectId      string    `json:"projectId"`
	Name           string    `json:"name"`
	CreateTime     time.Time `json:"createTime"`
	UpdateTime     time.Time `json:"updateTime"`
	LatestRevision *Revision `json:"latestRevision"`
}

type IntegrationName added in v0.1.14

type IntegrationName struct {
	Name string `json:"name"`
}

type PatchDestination added in v0.1.16

type PatchDestination struct {
	Destination map[string]any `json:"destination"`
	UpdateMask  []string       `json:"updateMask"`
}

type ProblemError added in v0.1.13

type ProblemError struct {
	Detail       string                 `json:"detail,omitempty"`
	Href         string                 `json:"href,omitempty"`
	Instance     string                 `json:"instance,omitempty"`
	Status       int32                  `json:"status,omitempty"`
	Title        string                 `json:"title,omitempty"`
	Type         string                 `json:"type,omitempty"`
	Subsystem    string                 `json:"subsystem,omitempty"`
	Time         string                 `json:"time,omitempty"`
	RequestID    string                 `json:"requestId,omitempty"`
	Causes       []string               `json:"causes,omitempty"`
	Remedy       string                 `json:"remedy,omitempty"`
	SupportEmail string                 `json:"supportEmail,omitempty"`
	SupportPhone string                 `json:"supportPhone,omitempty"`
	SupportURL   string                 `json:"supportUrl,omitempty"`
	Retryable    *bool                  `json:"retryable,omitempty"`
	RetryAfter   string                 `json:"retryAfter,omitempty"`
	Context      map[string]any         `json:"context,omitempty"`
	Issues       []InputValidationIssue `json:"issues,omitempty"`
}

func (*ProblemError) Error added in v0.1.13

func (p *ProblemError) Error() string

type Project added in v0.1.15

type Project struct {
	Id         string    `json:"id"`
	AppName    string    `json:"appName"`
	Name       string    `json:"name"`
	CreateTime time.Time `json:"createTime"`
	OrgId      string    `json:"orgId"`
}

type ProviderApp added in v0.1.14

type ProviderApp struct {
	Id           string    `json:"id"`
	CreateTime   time.Time `json:"createTime"`
	UpdateTime   time.Time `json:"updateTime"`
	ExternalRef  string    `json:"externalRef"`
	Provider     string    `json:"provider"`
	ClientId     string    `json:"clientId"`
	ClientSecret string    `json:"clientSecret,omitempty"`
	Scopes       []string  `json:"scopes"`
	ProjectId    string    `json:"projectId"`
}

type Revision added in v0.1.14

type Revision struct {
	Id            string              `json:"id"`
	IntegrationId string              `json:"integrationId"`
	CreateTime    time.Time           `json:"createTime"`
	Content       openapi.Integration `json:"content"`
	SpecVersion   string              `json:"specVersion"`
}

type SignedURL added in v0.1.3

type SignedURL struct {
	URL    string `json:"url"`
	Bucket string `json:"bucket"`
	Path   string `json:"path"`
}

type WebhookMetadata added in v0.1.16

type WebhookMetadata struct {
	URL            string            `json:"url"`
	Headers        map[string]string `json:"headers,omitempty"`
	SvixAppId      string            `json:"svixAppId,omitempty"`
	SvixEndpointId string            `json:"svixEndpointId,omitempty"`
}

Jump to

Keyboard shortcuts

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