common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundError added in v0.20.0

func IsNotFoundError(err error) bool

func ParseOrganizationURL

func ParseOrganizationURL(raw string) (string, error)

ParseOrganizationURL validates a Semaphore organization URL and returns the origin only (https + host + optional port). Trailing slashes, extra paths, query strings, and a missing https scheme are accepted and normalized.

Types

type Client

type Client struct {
	OrgURL   string
	APIToken string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(http core.HTTPContext, ctx core.IntegrationContext) (*Client, error)

func NewClientWithAPIToken

func NewClientWithAPIToken(http core.HTTPContext, parameters core.IntegrationPropertyStorageReader, apiToken string) (*Client, error)

func (*Client) CreateNotification

func (c *Client) CreateNotification(params any) (*Notification, error)

func (*Client) CreateWebhookSecret

func (c *Client) CreateWebhookSecret(name, key string) (*Secret, error)

func (*Client) DeleteNotification

func (c *Client) DeleteNotification(id string) error

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(name string) error

func (*Client) GetNotification

func (c *Client) GetNotification(id string) (*Notification, error)

func (*Client) GetPipeline

func (c *Client) GetPipeline(id string) (*Pipeline, error)

func (*Client) GetProject

func (c *Client) GetProject(idOrName string) (*ProjectResponse, error)

func (*Client) GetSecret

func (c *Client) GetSecret(id string) (*Secret, error)

func (*Client) ListPipelines

func (c *Client) ListPipelines(projectID string) ([]any, error)

func (*Client) ListProjects

func (c *Client) ListProjects() ([]ProjectResponse, error)

func (*Client) RunWorkflow

func (c *Client) RunWorkflow(params any) (*CreateWorkflowResponse, error)

type CreateWorkflowResponse

type CreateWorkflowResponse struct {
	WorkflowID string `json:"workflow_id"`
	PipelineID string `json:"pipeline_id"`
}

type HTTPError added in v0.20.0

type HTTPError struct {
	StatusCode int
	Body       string
}

func (*HTTPError) Error added in v0.20.0

func (e *HTTPError) Error() string

type Notification

type Notification struct {
	APIVersion string               `json:"apiVersion"`
	Kind       string               `json:"kind"`
	Metadata   NotificationMetadata `json:"metadata"`
	Spec       NotificationSpec     `json:"spec"`
}

type NotificationMetadata

type NotificationMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type NotificationNotifySlack

type NotificationNotifySlack struct {
	Endpoint string   `json:"endpoint,omitempty"`
	Channels []string `json:"channels,omitempty"`
}

type NotificationNotifyWebhook

type NotificationNotifyWebhook struct {
	Endpoint string `json:"endpoint"`
	Secret   string `json:"secret"`
}

type NotificationRule

type NotificationRule struct {
	Name   string                 `json:"name"`
	Filter NotificationRuleFilter `json:"filter"`
	Notify NotificationRuleNotify `json:"notify"`
}

type NotificationRuleFilter

type NotificationRuleFilter struct {
	Branches  []string `json:"branches"`
	Pipelines []string `json:"pipelines"`
	Projects  []string `json:"projects"`
	Results   []string `json:"results"`
}

type NotificationRuleNotify

type NotificationRuleNotify struct {
	Webhook NotificationNotifyWebhook `json:"webhook"`

	// TODO
	// we don't really need this, but if it's not in the request,
	// the API does not work properly.
	// Once it's fixed, or we migrate to v2 API, we can remove it from here.
	//
	Slack NotificationNotifySlack `json:"slack"`
}

type NotificationSpec

type NotificationSpec struct {
	Rules []NotificationRule `json:"rules"`
}

type Pipeline

type Pipeline struct {
	PipelineName     string `json:"name"`
	PipelineID       string `json:"ppl_id"`
	WorkflowID       string `json:"wf_id"`
	State            string `json:"state"`
	Result           string `json:"result"`
	ResultReason     string `json:"result_reason"`
	BranchName       string `json:"branch_name"`
	CommitSHA        string `json:"commit_sha"`
	CommitMessage    string `json:"commit_message"`
	YAMLFileName     string `json:"yaml_file_name"`
	WorkingDirectory string `json:"working_directory"`
	ProjectID        string `json:"project_id"`
	CreatedAt        string `json:"created_at"`
	DoneAt           string `json:"done_at"`
	RunningAt        string `json:"running_at"`
	ErrorDescription string `json:"error_description"`
	TerminatedBy     string `json:"terminated_by"`
	PromotionOf      string `json:"promotion_of"`
}

type PipelineResponse

type PipelineResponse struct {
	Pipeline *Pipeline `json:"pipeline"`
}

type ProjectMetadata

type ProjectMetadata struct {
	ProjectName string `json:"name"`
	ProjectID   string `json:"id"`
}

type ProjectResponse

type ProjectResponse struct {
	Metadata *ProjectMetadata `json:"metadata"`
	Spec     *ProjectSpec     `json:"spec"`
}

type ProjectSpec

type ProjectSpec struct {
	Repository struct {
		URL string `json:"url"`
	} `json:"repository"`
}

type Secret

type Secret struct {
	APIVersion string         `json:"apiVersion"`
	Kind       string         `json:"kind"`
	Metadata   SecretMetadata `json:"metadata"`
	Data       SecretSpecData `json:"data"`
}

type SecretMetadata

type SecretMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type SecretSpecData

type SecretSpecData struct {
	EnvVars []SecretSpecDataEnvVar `json:"env_vars"`
}

type SecretSpecDataEnvVar

type SecretSpecDataEnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type WebhookConfiguration

type WebhookConfiguration struct {
	Project string `json:"project"`
}

Jump to

Keyboard shortcuts

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