approvals

package
v2.118.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

Get returns a paginated collection of server-task approvals matching the query.

Types

type Approval

type Approval struct {
	Id                   string         `json:"Id,omitempty"`
	SpaceId              string         `json:"SpaceId,omitempty"`
	Name                 string         `json:"Name,omitempty"`
	ServerTaskApprovalId string         `json:"ServerTaskApprovalId"`
	UserId               string         `json:"UserId,omitempty"`
	ApproverUsername     string         `json:"ApproverUsername,omitempty"`
	ApproverDisplayName  string         `json:"ApproverDisplayName,omitempty"`
	ApproverEmailAddress string         `json:"ApproverEmailAddress,omitempty"`
	Status               ApprovalStatus `json:"Status"`
	Notes                string         `json:"Notes"`
}

Approval is a single person's decision recorded against a ServerTaskApproval.

When returned from a list, ServerTaskApprovalId identifies the server task approval the vote was cast against, which is not necessarily the one that was queried: votes are tallied across every server task approval sharing a change request. The Approver fields are populated by the server and ignored on write.

func AddApproval

func AddApproval(client newclient.Client, spaceID string, serverTaskApprovalID string, approval *Approval) (*Approval, error)

AddApproval records a new decision (approve/reject) against a server-task approval.

A user may vote only once per change request, so this fails when the user has already voted against any server task approval sharing the change request. It also fails when the change is no longer active or has left the PreApproval state, or when the approval rule snapshot that governed the change request is no longer available.

func GetApprovalByID

func GetApprovalByID(client newclient.Client, spaceID string, serverTaskApprovalID string, ID string) (*Approval, error)

GetApprovalByID returns a single decision by ID.

func ListApprovals

func ListApprovals(client newclient.Client, spaceID string, serverTaskApprovalID string) ([]*Approval, error)

ListApprovals returns the individual decisions recorded for the change request that the given server-task approval belongs to. The server returns a bare array (not a paginated collection).

The result is scoped to the change request rather than to serverTaskApprovalID: entries may carry a different ServerTaskApprovalId when sibling server tasks share the same ChangeRequest.Id. Votes are deduplicated to one per user, with a rejection taking precedence over an approval.

func UpdateApproval

func UpdateApproval(client newclient.Client, spaceID string, serverTaskApprovalID string, approval *Approval) (*Approval, error)

UpdateApproval modifies an existing decision. It fails once the change has completed, that is when the change is inactive or has left the PreApproval state.

type ApprovalStatus

type ApprovalStatus string

ApprovalStatus is an individual approver's decision.

const (
	ApprovalStatusApproved ApprovalStatus = "Approved"
	ApprovalStatusRejected ApprovalStatus = "Rejected"
)

type ChangeRequest

type ChangeRequest struct {
	Id                         string                     `json:"Id"`
	Number                     string                     `json:"Number,omitempty"`
	Description                string                     `json:"Description"`
	Active                     bool                       `json:"Active"`
	Type                       string                     `json:"Type,omitempty"`
	ChangeRequestApprovalState ChangeRequestApprovalState `json:"ChangeRequestApprovalState"`
	Self                       string                     `json:"Self,omitempty"`
}

ChangeRequest is the (optionally ITSM-backed) change associated with a server-task approval. Its Id is the key that groups server task approvals: deployments are gated per change request, and several server tasks can share one — for example the tenants of a release when the governing approval rule uses the PerRelease tenant approval strategy. Approval votes are tallied across every server task approval sharing an Id. There is no dedicated change request endpoint on the API; use Get or GetAll and group by this Id.

type ChangeRequestApprovalState

type ChangeRequestApprovalState string

ChangeRequestApprovalState is the state of the change carried by a server-task approval.

const (
	ChangeRequestApprovalStatePreApproval  ChangeRequestApprovalState = "PreApproval"
	ChangeRequestApprovalStateApproved     ChangeRequestApprovalState = "Approved"
	ChangeRequestApprovalStatePostApproval ChangeRequestApprovalState = "PostApproval"
)

type NamedReferenceItem

type NamedReferenceItem struct {
	Id               string `json:"Id"`
	DisplayName      string `json:"DisplayName"`
	DisplayIdAndName bool   `json:"DisplayIdAndName"`
}

NamedReferenceItem is a lightweight id/display-name reference used for approving users/teams.

type ServerTaskApproval

type ServerTaskApproval struct {
	Id                 string        `json:"Id"`
	ServerTaskId       string        `json:"ServerTaskId"`
	SpaceId            string        `json:"SpaceId"`
	ApprovalProviderId string        `json:"ApprovalProviderId"`
	Name               string        `json:"Name"`
	ChangeRequest      ChangeRequest `json:"ChangeRequest"`
}

ServerTaskApproval is the approval requirement attached to a server task (list / get-by-id representation).

func GetAll

func GetAll(client newclient.Client, spaceID string) ([]*ServerTaskApproval, error)

GetAll returns all server-task approvals in the space, following pagination links.

func GetByID

func GetByID(client newclient.Client, spaceID string, ID string) (*ServerTaskApproval, error)

GetByID returns the server-task approval that matches the input ID.

type ServerTaskApprovalDetail

type ServerTaskApprovalDetail struct {
	Id                       string               `json:"Id"`
	SpaceId                  string               `json:"SpaceId"`
	Approvals                []Approval           `json:"Approvals"`
	ApprovalState            string               `json:"ApprovalState"`
	ApprovingUsers           []NamedReferenceItem `json:"ApprovingUsers,omitempty"`
	ApprovingTeams           []NamedReferenceItem `json:"ApprovingTeams,omitempty"`
	ApprovalsCount           int                  `json:"ApprovalsCount"`
	MinimumApproversRequired int                  `json:"MinimumApproversRequired"`
}

ServerTaskApprovalDetail is the richer representation returned by the by-task-id endpoint.

func GetByTaskID

func GetByTaskID(client newclient.Client, spaceID string, serverTaskID string) (*ServerTaskApprovalDetail, error)

GetByTaskID returns the approval detail for a server task. Returns (nil, nil) when the task has no approval requirement (approvals disabled, not a deployment/runbook, or no approval rule applies).

Approvals and ApprovalsCount are tallied across the whole change request, not just this server task: they include votes cast against sibling server task approvals that share the same ChangeRequest.Id, deduplicated to one vote per user with a rejection taking precedence.

type ServerTaskApprovalsQuery

type ServerTaskApprovalsQuery struct {
	ProviderId string `uri:"providerId,omitempty" url:"providerId,omitempty"`
	State      string `uri:"state,omitempty" url:"state,omitempty"`
	Skip       int    `uri:"skip" url:"skip"`
	Take       int    `uri:"take,omitempty" url:"take,omitempty"`
}

ServerTaskApprovalsQuery is the query for the paginated server-task approvals list endpoint.

Jump to

Keyboard shortcuts

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