client

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NF = -1
)

Variables

View Source
var (
	ErrUserNotFound = fmt.Errorf("user not found")
)

Functions

func IsUrl

func IsUrl(str string) bool

Types

type Actors

type Actors struct {
	ID          int    `json:"id,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	Type        string `json:"type,omitempty"`
	Name        string `json:"name,omitempty"`
}

type ActorsAPIData

type ActorsAPIData struct {
	Self        string   `json:"self,omitempty"`
	Name        string   `json:"name,omitempty"`
	ID          int      `json:"id,omitempty"`
	Description string   `json:"description,omitempty"`
	Actors      []Actors `json:"actors,omitempty"`
}

type AvatarUrls

type AvatarUrls struct {
	Four8X48  string `json:"48x48"`
	Two4X24   string `json:"24x24"`
	One6X16   string `json:"16x16"`
	Three2X32 string `json:"32x32"`
}

type BodyActors

type BodyActors struct {
	Group []string `json:"group,omitempty"`
	User  []string `json:"user,omitempty"`
	Name  string   `json:"name,omitempty"`
}

type Client

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

func New

func New(ctx context.Context, instanceURL, accessToken string) (*Client, error)

func (*Client) AddActorsToProjectRole

func (client *Client) AddActorsToProjectRole(ctx context.Context, projectId, roleId string, body BodyActors) (ActorsAPIData, error)

AddActorsToProjectRole Adds an actor (user or group) to a project role in the Jira DC. For user actors, their usernames should be used. https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2/project/{projectIdOrKey}/role-addActorUsers

func (*Client) AddProjectRoleActorsToRole

func (client *Client) AddProjectRoleActorsToRole(ctx context.Context, roleId string, body BodyActors) (ActorsAPIData, error)

AddProjectRoleActorsToRole Adds default actors to the given role. The request data should contain a list of usernames or a list of groups to add. https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/role-addProjectRoleActorsToRole

func (*Client) AddUserToGroup

func (client *Client) AddUserToGroup(ctx context.Context, groupName, userName string) (int, error)

AddUserToGroup Adds given user to a group in the Jira DC. Returns the current state of the group. https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2/group-addUserToGroup

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, projectKey string, summary string, opts ...FieldOption) (*jira.Issue, error)

func (*Client) DeleteProjectRoleActorsFromRole

func (client *Client) DeleteProjectRoleActorsFromRole(ctx context.Context, roleId, actor, actorName string) (int, error)

DeleteProjectRoleActorsFromRole Removes default actor from the given role. https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/role-deleteProjectRoleActorsFromRole

func (*Client) GetGroupLabelRoles

func (client *Client) GetGroupLabelRoles(ctx context.Context, groupName string) ([]Labels, error)

GetGroupLabelRoles Return group label roles.

func (*Client) GetGroupMembers

func (client *Client) GetGroupMembers(ctx context.Context, groupName string) ([]GroupUser, error)

GetGroupMembers Returns all members that are present in a group.

func (*Client) GetGroupRole

func (client *Client) GetGroupRole(ctx context.Context) ([]Group, error)

GetGroupRole Return all group roles.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, issueID string) (*jira.Issue, error)

func (*Client) GetIssueTypeFields

func (c *Client) GetIssueTypeFields(ctx context.Context, projectKey, issueTypeId string, opts *jira.GetQueryIssueTypeOptions) ([]*jira.MetaDataFields, error)

func (*Client) GetIssueTypesForProject

func (c *Client) GetIssueTypesForProject(ctx context.Context, projectKey string, opts *jira.GetQueryIssueTypeOptions) ([]*jira.MetaIssueType, error)

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, projectID string) (*jira.Project, error)

func (*Client) GetProjectRoleDetails

func (client *Client) GetProjectRoleDetails(ctx context.Context, urlApi string) (RolesAPIData, error)

GetProjectRoleDetails Returns all role details that are present in specific project.

func (*Client) GetProjectRoles

func (client *Client) GetProjectRoles(ctx context.Context, projectId string) (map[string]string, error)

GetProjectRoles Returns all roles that are present in specific project.

func (*Client) GetRole

func (client *Client) GetRole(ctx context.Context, roleId string) (RolesAPIData, error)

GetRole Return specific role.

func (*Client) GetUser

func (client *Client) GetUser(ctx context.Context, userName string) (jira.User, error)

GetUser Returns specific users.

func (*Client) GetUserName

func (client *Client) GetUserName(ctx context.Context, userId string) (string, error)

GetUserName Returns user name.

func (*Client) ListAllGroups

func (client *Client) ListAllGroups(ctx context.Context) ([]Group, error)

ListAllGroups Returns all groups that are present in the Jira instance.

func (*Client) ListAllPermissionScheme

func (client *Client) ListAllPermissionScheme(ctx context.Context) (PermissionSchemes, error)

ListAllPermissionScheme Returns all permission schemes that are present in the Jira DC.

func (*Client) ListAllPermissions

func (client *Client) ListAllPermissions(ctx context.Context) ([]Permission, error)

ListAllPermissions Returns all permissions that are present in the Jira instance https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2-getAllPermissions

func (*Client) ListAllRoles

func (client *Client) ListAllRoles(ctx context.Context) ([]RolesAPIData, error)

ListAllRoles Returns all roles that are present in the Jira instance.

func (*Client) ListAllUsers

func (client *Client) ListAllUsers(ctx context.Context) ([]jira.User, error)

ListAllUsers Returns all users that are present in the Jira instance.

func (*Client) ListProjects

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

func (*Client) ListStatuses

func (c *Client) ListStatuses(ctx context.Context) ([]*jira.Status, error)

func (*Client) ListStatusesForProject

func (c *Client) ListStatusesForProject(ctx context.Context, projectID string) ([]*jira.Status, error)

func (*Client) Myself

func (client *Client) Myself(ctx context.Context) error

func (*Client) RemoveActorsFromProjectRole

func (client *Client) RemoveActorsFromProjectRole(ctx context.Context, projectId, roleId, actor, actorName string) (int, error)

RemoveActorsProjectRole Deletes actors (users or groups) from a project role in the Jira DC. https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2/project/{projectIdOrKey}/role-deleteActor

func (*Client) RemoveUserFromGroup

func (client *Client) RemoveUserFromGroup(ctx context.Context, groupName, userName string) (int, error)

RemoveUserFromGroup Removes given user from a group in the Jira DC. https://docs.atlassian.com/software/jira/docs/api/REST/9.14.0/#api/2/group-removeUserFromGroup

type FieldOption

type FieldOption func(issue *jira.Issue)

func WithComponents

func WithComponents(componentIDs ...string) FieldOption

func WithCustomField

func WithCustomField(id string, value interface{}) FieldOption

func WithDescription

func WithDescription(description string) FieldOption

func WithLabels

func WithLabels(labels ...string) FieldOption

func WithStatus

func WithStatus(statusId string) FieldOption

func WithType

func WithType(id string) FieldOption

type Group

type Group struct {
	Name   string   `json:"name,omitempty"`
	HTML   string   `json:"html,omitempty"`
	Labels []Labels `json:"labels,omitempty"`
}

type GroupMembersAPIData

type GroupMembersAPIData struct {
	Self       string      `json:"self,omitempty"`
	MaxResults int         `json:"maxResults,omitempty"`
	StartAt    int         `json:"startAt,omitempty"`
	Total      int         `json:"total,omitempty"`
	IsLast     bool        `json:"isLast,omitempty"`
	Users      []GroupUser `json:"values,omitempty"`
}

type GroupRolesAPIData

type GroupRolesAPIData struct {
	Header string  `json:"header,omitempty"`
	Total  int     `json:"total,omitempty"`
	Groups []Group `json:"groups,omitempty"`
}

type GroupUser

type GroupUser struct {
	Self         string     `json:"self,omitempty"`
	Name         string     `json:"name,omitempty"`
	Key          string     `json:"key,omitempty"`
	EmailAddress string     `json:"emailAddress,omitempty"`
	AvatarUrls   AvatarUrls `json:"avatarUrls,omitempty"`
	DisplayName  string     `json:"displayName,omitempty"`
	Active       bool       `json:"active,omitempty"`
	TimeZone     string     `json:"timeZone,omitempty"`
}

type GroupsAPIData

type GroupsAPIData struct {
	Header string  `json:"header,omitempty"`
	Total  int     `json:"total,omitempty"`
	Groups []Group `json:"groups,omitempty"`
}

type Holder

type Holder struct {
	Type        string      `json:"type,omitempty"`
	Parameter   string      `json:"parameter,omitempty"`
	ProjectRole ProjectRole `json:"projectRole,omitempty"`
}

type JiraError

type JiraError struct {
	ErrorMessage     string                   `json:"error"`
	ErrorDescription string                   `json:"error_description"`
	ErrorCode        int                      `json:"errorCode,omitempty"`
	ErrorSummary     string                   `json:"errorSummary,omitempty" toml:"error_description"`
	ErrorLink        string                   `json:"errorLink,omitempty"`
	ErrorId          string                   `json:"errorId,omitempty"`
	ErrorCauses      []map[string]interface{} `json:"errorCauses,omitempty"`
}

func (*JiraError) Error

func (b *JiraError) Error() string

type Labels

type Labels struct {
	Text  string `json:"text,omitempty"`
	Title string `json:"title,omitempty"`
	Type  string `json:"type,omitempty"`
}

type Permission

type Permission struct {
	Key         string `json:"key,omitempty"`
	Name        string `json:"name,omitempty"`
	Type        string `json:"type,omitempty"`
	Description string `json:"description,omitempty"`
}

type PermissionSchemes

type PermissionSchemes struct {
	Expand      string        `json:"expand,omitempty"`
	ID          int           `json:"id,omitempty"`
	Self        string        `json:"self,omitempty"`
	Name        string        `json:"name,omitempty"`
	Description string        `json:"description,omitempty"`
	Permissions []Permissions `json:"permissions,omitempty"`
}

type PermissionSchemesAPIData

type PermissionSchemesAPIData struct {
	PermissionSchemes []PermissionSchemes `json:"permissionSchemes,omitempty"`
}

type Permissions

type Permissions struct {
	ID         int    `json:"id,omitempty"`
	Self       string `json:"self,omitempty"`
	Holder     Holder `json:"holder,omitempty"`
	Permission string `json:"permission,omitempty"`
}

type PermissionsAPIData

type PermissionsAPIData struct {
	Permissions map[string]any `json:"Permissions,omitempty"`
	Roles       []Permission   `json:"Roles,omitempty"`
}

type ProjectRole

type ProjectRole struct {
	Self        string `json:"self,omitempty"`
	Name        string `json:"name,omitempty"`
	Id          int    `json:"id,omitempty"`
	Description string `json:"description,omitempty"`
}

type Query

type Query map[string]string

type RolesAPIData

type RolesAPIData struct {
	Self        string   `json:"self,omitempty"`
	Name        string   `json:"name,omitempty"`
	ID          int      `json:"id,omitempty"`
	Description string   `json:"description,omitempty"`
	Actors      []Actors `json:"actors,omitempty"`
}

type UsersAPIData

type UsersAPIData struct {
	Self         string     `json:"self,omitempty"`
	Key          string     `json:"key,omitempty"`
	Name         string     `json:"name,omitempty"`
	EmailAddress string     `json:"emailAddress,omitempty"`
	AvatarUrls   AvatarUrls `json:"avatarUrls,omitempty"`
	DisplayName  string     `json:"displayName,omitempty"`
	Active       bool       `json:"active,omitempty"`
	Deleted      bool       `json:"deleted,omitempty"`
	TimeZone     string     `json:"timeZone,omitempty"`
	Locale       string     `json:"locale,omitempty"`
}

Jump to

Keyboard shortcuts

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