api

package
v0.15.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseIssue

func CloseIssue(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

CloseIssue @Summary set issue's status to DONE @Description set issue's status to DONE @Tags plugins/webhook @Success 200 {string} noResponse "" @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/:connectionId/issue/:boardKey/:issueKey/close [POST]

func DeleteConnection

func DeleteConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

DeleteConnection @Summary delete a webhook connection @Description Delete a webhook connection @Tags plugins/webhook @Success 200 {object} models.WebhookConnection @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/connections/{connectionId} [DELETE]

func GetConnection

func GetConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

GetConnection @Summary get webhook connection detail @Description Get webhook connection detail @Tags plugins/webhook @Success 200 {object} WebhookConnectionResponse @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/connections/{connectionId} [GET]

func Init

func Init(br core.BasicRes)

func ListConnections

func ListConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

ListConnections @Summary get all webhook connections @Description Get all webhook connections @Tags plugins/webhook @Success 200 {object} []WebhookConnectionResponse @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/connections [GET]

func MakeDataSourcePipelinePlanV200 added in v0.15.0

func MakeDataSourcePipelinePlanV200(connectionId uint64) (core.PipelinePlan, []core.Scope, errors.Error)

func PatchConnection

func PatchConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

PatchConnection @Summary patch webhook connection @Description Patch webhook connection @Tags plugins/webhook @Param body body models.WebhookConnection true "json body" @Success 200 {object} models.WebhookConnection @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/connections/{connectionId} [PATCH]

func PostCicdTask

func PostCicdTask(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

PostCicdTask @Summary create pipeline by webhook @Description Create pipeline by webhook.<br/> @Description example1: {"pipeline_name":"A123","name":"unit-test","result":"IN_PROGRESS","status":"IN_PROGRESS","type":"TEST","environment":"PRODUCTION","created_date":"2020-01-01T12:00:00+00:00","finished_date":"2020-01-01T12:59:59+00:00","repo_id":"devlake","branch":"main","commit_sha":"015e3d3b480e417aede5a1293bd61de9b0fd051d"}<br/> @Description example2: {"pipeline_name":"A123","name":"unit-test","result":"SUCCESS","status":"DONE","type":"DEPLOYMENT","environment":"PRODUCTION","created_date":"2020-01-01T12:00:00+00:00","finished_date":"2020-01-01T12:59:59+00:00","repo_id":"devlake","branch":"main","commit_sha":"015e3d3b480e417aede5a1293bd61de9b0fd051d"}<br/> @Description When request webhook first time for each pipeline, it will be created. @Description So we suggest request before task start and after pipeline finish. @Description Remember fill all data to request after pipeline finish. @Tags plugins/webhook @Param body body WebhookTaskRequest true "json body" @Success 200 @Failure 400 {string} errcode.Error "Bad Request" @Failure 403 {string} errcode.Error "Forbidden" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/:connectionId/cicd_tasks [POST]

func PostConnections

func PostConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

PostConnections @Summary create webhook connection @Description Create webhook connection, example: {"name":"Webhook data connection name"} @Tags plugins/webhook @Param body body models.WebhookConnection true "json body" @Success 200 {object} models.WebhookConnection @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/connections [POST]

func PostDeploymentCicdTask added in v0.14.2

func PostDeploymentCicdTask(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

PostCicdTask @Summary create deployment pipeline by webhook @Description Create deployment pipeline by webhook.<br/> @Description example1: {"repo_url":"devlake","commit_sha":"015e3d3b480e417aede5a1293bd61de9b0fd051d","start_time":"2020-01-01T12:00:00+00:00","end_time":"2020-01-01T12:59:59+00:00","environment":"PRODUCTION"}<br/> @Description So we suggest request before task after deployment pipeline finish. @Description Both cicd_pipeline and cicd_task will be created @Tags plugins/webhook @Param body body WebhookDeployTaskRequest true "json body" @Success 200 @Failure 400 {string} errcode.Error "Bad Request" @Failure 403 {string} errcode.Error "Forbidden" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/:connectionId/deployments [POST]

func PostIssue

PostIssue @Summary receive a record as defined and save it @Description receive a record as follow and save it, example: {"board_key":"DLK","url":"","issue_key":"DLK-1234","title":"a feature from DLK","description":"","epic_key":"","type":"BUG","status":"TODO","original_status":"created","story_point":0,"resolution_date":null,"created_date":"2020-01-01T12:00:00+00:00","updated_date":null,"lead_time_minutes":0,"parent_issue_key":"DLK-1200","priority":"","original_estimate_minutes":0,"time_spent_minutes":0,"time_remaining_minutes":0,"creator_id":"user1131","creator_name":"Nick name 1","assignee_id":"user1132","assignee_name":"Nick name 2","severity":"","component":""} @Tags plugins/webhook @Param body body WebhookIssueRequest true "json body" @Success 200 {string} noResponse "" @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/:connectionId/issues [POST]

func PostPipelineFinish

func PostPipelineFinish(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error)

PostPipelineFinish @Summary set pipeline's status to DONE @Description set pipeline's status to DONE and cal duration @Tags plugins/webhook @Success 200 @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /plugins/webhook/:connectionId/cicd_pipeline/:pipelineName/finish [POST]

Types

type WebhookConnectionResponse

type WebhookConnectionResponse struct {
	models.WebhookConnection
	PostIssuesEndpoint             string `json:"postIssuesEndpoint"`
	CloseIssuesEndpoint            string `json:"closeIssuesEndpoint"`
	PostPipelineTaskEndpoint       string `json:"postPipelineTaskEndpoint"`
	PostPipelineDeployTaskEndpoint string `json:"postPipelineDeployTaskEndpoint"`
	ClosePipelineEndpoint          string `json:"closePipelineEndpoint"`
}

type WebhookDeployTaskRequest added in v0.14.2

type WebhookDeployTaskRequest struct {
	// RepoUrl should be unique string, fill url or other unique data
	RepoUrl   string `mapstructure:"repo_url" validate:"required"`
	CommitSha string `mapstructure:"commit_sha" validate:"required"`
	// start_time and end_time is more readable for users,
	// StartedDate and FinishedDate is same as columns in db.
	// So they all keep.
	StartedDate  *time.Time `mapstructure:"start_time" validate:"required_with=FinishedDate"`
	FinishedDate *time.Time `mapstructure:"end_time"`
	Environment  string     `validate:"omitempty,oneof=PRODUCTION STAGING TESTING DEVELOPMENT"`
}

type WebhookIssueRequest

type WebhookIssueRequest struct {
	BoardKey                string     `mapstructure:"board_key" validate:"required"`
	Url                     string     `mapstructure:"url"`
	IssueKey                string     `mapstructure:"issue_key" validate:"required"`
	Title                   string     `mapstructure:"title" validate:"required"`
	Description             string     `mapstructure:"description"`
	EpicKey                 string     `mapstructure:"epic_key"`
	Type                    string     `mapstructure:"type"`
	Status                  string     `mapstructure:"status" validate:"oneof=TODO DONE IN_PROGRESS"`
	OriginalStatus          string     `mapstructure:"original_status" validate:"required"`
	StoryPoint              int64      `mapstructure:"story_point"`
	ResolutionDate          *time.Time `mapstructure:"resolution_date"`
	CreatedDate             *time.Time `mapstructure:"created_date" validate:"required"`
	UpdatedDate             *time.Time `mapstructure:"updated_date"`
	LeadTimeMinutes         uint       `mapstructure:"lead_time_minutes"`
	ParentIssueKey          string     `mapstructure:"parent_issue_key"`
	Priority                string     `mapstructure:"priority"`
	OriginalEstimateMinutes int64      `mapstructure:"original_estimate_minutes"`
	TimeSpentMinutes        int64      `mapstructure:"time_spent_minutes"`
	TimeRemainingMinutes    int64      `mapstructure:"time_remaining_minutes"`
	CreatorId               string     `mapstructure:"creator_id"`
	CreatorName             string     `mapstructure:"creator_name"`
	AssigneeId              string     `mapstructure:"assignee_id"`
	AssigneeName            string     `mapstructure:"assignee_name"`
	Severity                string     `mapstructure:"severity"`
	Component               string     `mapstructure:"component"`
}

type WebhookTaskRequest

type WebhookTaskRequest struct {
	// PipelineName can be filled by any string unique in one pipeline
	PipelineName string `mapstructure:"pipeline_name" validate:"required"`

	Name         string     `validate:"required"` // Name should be unique in one pipeline
	Result       string     `validate:"oneof=SUCCESS FAILURE ABORT IN_PROGRESS"`
	Status       string     `validate:"oneof=IN_PROGRESS DONE"`
	Type         string     `validate:"oneof=TEST LINT BUILD DEPLOYMENT"`
	Environment  string     `validate:"oneof=PRODUCTION STAGING TESTING"`
	StartedDate  time.Time  `mapstructure:"created_date" validate:"required"`
	FinishedDate *time.Time `mapstructure:"finished_date"`

	RepoId    string `mapstructure:"repo_id" validate:"required"` // RepoId should be unique string
	Branch    string
	CommitSha string `mapstructure:"commit_sha"`
}

Jump to

Keyboard shortcuts

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