rest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OrgSlug

func OrgSlug(vcs, org string) string

func Slug

func Slug(vcs, org, project string) string

Slug returns a project slug, including the VCS, organization, and project names

Types

type Client

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

func New

func New(config Config) *Client

func (*Client) DoRequest

func (c *Client) DoRequest(req *http.Request, resp interface{}) (statusCode int, err error)

func (*Client) GetCurrentLogin added in v1.0.0

func (c *Client) GetCurrentLogin() (*CurrentLogin, error)

func (*Client) HasProjectEnvironmentVariable

func (c *Client) HasProjectEnvironmentVariable(vcs, org, project, name string) (bool, error)

func (*Client) ListAllContext added in v0.1.0

func (c *Client) ListAllContext(organizationSlug string) ([]Context, error)

func (*Client) ListAllInsightsWorkflowRuns added in v0.3.0

func (c *Client) ListAllInsightsWorkflowRuns(projectSlug, workflowName, branch, startDate, endDate string, logger hclog.Logger) ([]InsightsWorkflowRun, error)

func (*Client) ListContext added in v0.1.0

func (c *Client) ListContext(organizationSlug, pageToken string) (*ContextResponse, error)

func (*Client) ListContextEnvironmentVariable added in v0.1.0

func (c *Client) ListContextEnvironmentVariable(contextId, pageToken string) (*EnvironmentVariableResponse, error)

func (*Client) ListInsightsWorkflowRuns added in v0.3.0

func (c *Client) ListInsightsWorkflowRuns(projectSlug, workflowName, branch, startDate, endDate, pageToken string, logger hclog.Logger) (*InsightsWorkflowRunResponse, error)

func (*Client) ListOrganizations added in v0.1.0

func (c *Client) ListOrganizations() (*[]OrganizationResponse, error)

func (*Client) ListPipelines

func (c *Client) ListPipelines(vcs, org string) (*PipelineResponse, error)

func (*Client) ListPipelinesWorkflow

func (c *Client) ListPipelinesWorkflow(pipelineId string) (*WorkflowResponse, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method string, u *url.URL, payload interface{}) (req *http.Request, err error)

type Config

type Config struct {
	URL   string
	Token string
}

type Context added in v0.1.0

type Context struct {
	ID               string    `json:"id"`
	OrganizationSlug string    `json:"slug"`
	Name             string    `json:"name"`
	CreatedAt        time.Time `json:"created_at"`
}

type ContextResponse added in v0.1.0

type ContextResponse struct {
	Items         []Context `json:"items"`
	NextPageToken string    `json:"next_page_token"`
}

type CurrentLogin added in v1.0.0

type CurrentLogin struct {
	Name  string `json:"name"`
	Login string `json:"login"`
	ID    string `json:"id"`
}

type EnvironmentVariable added in v0.1.0

type EnvironmentVariable struct {
	ContextID string    `json:"context_id"`
	Variable  string    `json:"variable"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type EnvironmentVariableResponse added in v0.1.0

type EnvironmentVariableResponse struct {
	Items         []EnvironmentVariable `json:"items"`
	NextPageToken string                `json:"next_page_token"`
}

type HTTPError

type HTTPError struct {
	Code    int
	Message string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type InsightsWorkflowRun added in v0.3.0

type InsightsWorkflowRun struct {
	ID           string    `json:"id"`
	WorkflowName string    `json:"workflow_name"`
	ProjectSlug  string    `json:"project_slug"`
	Branch       string    `json:"branch"`
	Duration     int       `json:"duration"`
	CreatedAt    time.Time `json:"created_at"`
	StoppedAt    time.Time `json:"stopped_at"`
	CreditsUsed  int       `json:"credits_used"`
	Status       string    `json:"status"`
}

type InsightsWorkflowRunResponse added in v0.3.0

type InsightsWorkflowRunResponse struct {
	Items         []InsightsWorkflowRun `json:"items"`
	NextPageToken string                `json:"next_page_token"`
}

type OrganizationResponse added in v0.1.0

type OrganizationResponse struct {
	VcsType   string    `json:"vcs_type"`
	Slug      string    `json:"slug"`
	Name      string    `json:"name"`
	ID        string    `json:"id"`
	AvatarURL string    `json:"avatar_url"`
	Contexts  []Context `json:"context"`
}

type PipelineResponse

type PipelineResponse struct {
	Items []struct {
		ID     string `json:"id"`
		Errors []struct {
			Type    string `json:"type"`
			Message string `json:"message"`
		} `json:"errors"`
		ProjectSlug       string                 `json:"project_slug"`
		UpdatedAt         time.Time              `json:"updated_at"`
		Number            int                    `json:"number"`
		TriggerParameters map[string]interface{} `json:"trigger_parameters"`
		State             string                 `json:"state"`
		CreatedAt         time.Time              `json:"created_at"`
		Trigger           struct {
			Type       string    `json:"type"`
			ReceivedAt time.Time `json:"received_at"`
			Actor      struct {
				Login     string `json:"login"`
				AvatarURL string `json:"avatar_url"`
			} `json:"actor"`
		} `json:"trigger"`
		Vcs struct {
			ProviderName        string `json:"provider_name"`
			TargetRepositoryURL string `json:"target_repository_url"`
			Branch              string `json:"branch"`
			ReviewID            string `json:"review_id"`
			ReviewURL           string `json:"review_url"`
			Revision            string `json:"revision"`
			Tag                 string `json:"tag"`
			Commit              struct {
				Subject string `json:"subject"`
				Body    string `json:"body"`
			} `json:"commit"`
			OriginRepositoryURL string `json:"origin_repository_url"`
		} `json:"vcs"`
	} `json:"items"`
	NextPageToken string `json:"next_page_token"`
}

type Workflow added in v0.3.0

type Workflow struct {
	PipelineID     string    `json:"pipeline_id"`
	CanceledBy     string    `json:"canceled_by"`
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	ProjectSlug    string    `json:"project_slug"`
	ErroredBy      string    `json:"errored_by"`
	Tag            string    `json:"tag"`
	Status         string    `json:"status"`
	StartedBy      string    `json:"started_by"`
	PipelineNumber int       `json:"pipeline_number"`
	CreatedAt      time.Time `json:"created_at"`
	StoppedAt      time.Time `json:"stopped_at"`
}

type WorkflowResponse

type WorkflowResponse struct {
	Items         []Workflow `json:"items"`
	NextPageToken string     `json:"next_page_token"`
}

Jump to

Keyboard shortcuts

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