tracker

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 4 Imported by: 0

README

Yandex.Tracker API in Go

This is the original Yandex.Tracker library for Go.

Install

go get -u github.com/dvsnin/yandex-tracker-go

Example

Getting ticket and description
import (
    "fmt"
	
    "github.com/dvsnin/yandex-tracker-go"
)

func main() {
    client := tracker.New("YOUR YANDEX.TRACKER TOKEN", "YOUR YANDEX ORG_ID")
    ticket, err := client.GetTicket("TICKET KEY")
    if err != nil {
    	fmt.Printf("%v\n", err)
        return
    }
    fmt.Printf("%s\n", ticket.Description())
}
Edit ticket fields
import (
    "fmt"

    "github.com/dvsnin/yandex-tracker-go"
)

func main() {
    client := tracker.New("YOUR YANDEX.TRACKER TOKEN", "YOUR YANDEX ORG_ID")
    ticket, err := client.PatchTicket("TICKET KEY", map[string]string{"TICKET FIELD": "NEW VALUE"})
    if err != nil {
    	fmt.Printf("%v\n", err)
        return
    }
    fmt.Printf("%s\n", ticket.Description())
}

Contributing

You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicIssue added in v1.0.4

type BasicIssue struct {
	// Address of the API resource with information about the issue.
	Self string `json:"self"`

	// Issue ID.
	ID string `json:"id"`

	// Issue key.
	Key string `json:"key"`

	// Issue name displayed.
	Display string `json:"display"`
}

Basic Issue structure in Yandex.Tracker

type BasicPriority added in v1.0.4

type BasicPriority struct {
	// Address of the API resource with information about the priority.
	Self string `json:"self"`

	// Priority ID.
	ID string `json:"id"`

	// Priority key.
	Key string `json:"key"`

	// Priority name displayed.
	Display string `json:"display"`
}

BasicPriority https://cloud.yandex.ru/en/docs/tracker/concepts/issues/get-issue#priority

type BasicQueue added in v1.0.4

type BasicQueue struct {
	// Address of the API resource with information about the queue.
	Self string `json:"self"`

	// Queue ID.
	ID string `json:"id"`

	// Queue key.
	Key string `json:"key"`

	// Queue name displayed.
	Display string `json:"display"`
}

type BasicSprint added in v1.0.4

type BasicSprint struct {
	// Address of the API resource with information about the sprint.
	Self string `json:"self"`

	// Sprint ID.
	ID string `json:"id"`

	// Sprint name displayed.
	Display string `json:"display"`
}

type BasicStatus added in v1.0.4

type BasicStatus struct {
	// Address of the API resource with information about the status.
	Self string `json:"self"`

	// Status ID.
	ID string `json:"id"`

	// Status key.
	Key string `json:"key"`

	// Status name displayed.
	Display string `json:"display"`
}

Status https://cloud.yandex.ru/en/docs/tracker/concepts/issues/get-issue#status

type BasicUser added in v1.0.4

type BasicUser struct {
	Self    string
	ID      string
	Display string
}

User Basic user structure in Yandex.Tracker

func (*BasicUser) Id added in v1.0.4

func (u *BasicUser) Id() string

Id Get user id

func (*BasicUser) Name added in v1.0.4

func (u *BasicUser) Name() string

Name Get username

type BasicUsers added in v1.0.4

type BasicUsers []BasicUser

type Client added in v1.0.4

type Client interface {
	// GetTicket - get Yandex.Tracker ticket by ticket keys
	GetTicket(ticketKey string) (ticket Ticket, err error)
	// PatchTicket - patch Yandex.Tracker ticket by ticket key
	PatchTicket(ticketKey string, body map[string]string) (ticket Ticket, err error)
	// GetTicketComments - get Yandex.Tracker ticket comments by ticket key
	GetTicketComments(ticketKey string) (comments TicketComments, err error)
	// Myself - get information about the current Yandex.Tracker user
	Myself() (user *User, err error)
	// CreateIssue - create Yandex.Tracker issue
	CreateIssue(opts *CreateIssueOptions) (issue *Issue, err error)
	// FindIssues - search Yandex.Tracker issues
	FindIssues(opts *FindIssuesOptions, listOpts *ListOptions) (issues []*Issue, err error)
}

func New

func New(token, xOrgID, xCloudOrgID string) Client

type CreateIssueOptions added in v1.0.4

type CreateIssueOptions struct {
	// Issue name. Required.
	Summary *string `json:"summary,omitempty"`

	// Queue in which to create the issue. Required.
	// Can be set as an object, a string (if the queue key is provided), or a number (if the queue ID is provided).
	Queue interface{} `json:"queue,omitempty"`

	// Parent issue.
	// Object or string.
	Parent interface{} `json:"parent,omitempty"`

	// Issue description.
	Description *string `json:"description,omitempty"`

	// Block with information about sprints.
	// Array of objects or strings.
	Sprint *[]interface{} `json:"sprint,omitempty"`

	// Issue type.
	// Can be set as an object, a string (if the issue type key is provided), or a number (if the issue type ID is provided).
	Type interface{} `json:"type,omitempty"`

	// Issue priority.
	// Can be set as an object, a string (if the priority key is provided), or a number (if the priority ID is provided).
	Priority interface{} `json:"priority,omitempty"`

	// IDs or usernames of issue followers.
	// Array of objects, numbers, or strings.
	Followers *[]interface{} `json:"followers,omitempty"`

	// ID or username of issue assignee.
	// Object, number, or string.
	Assignee interface{} `json:"assignee,omitempty"`

	// ID or username of issue author.
	// Object, number, or string.
	Author interface{} `json:"author,omitempty"`

	// Field with a unique value that disables creation of duplicate issues.
	// If you try to create an issue with the same value of this parameter again, no duplicate will be created and the response will contain an error with code 409.
	Unique *string `json:"unique,omitempty"`

	// List of attachment IDs.
	// Array of strings
	AttachmentIDs *[]string `json:"attachmentIds,omitempty"`
}

https://cloud.yandex.ru/en/docs/tracker/concepts/issues/create-issue

type FindIssuesOptions added in v1.0.4

type FindIssuesOptions struct {
	// Queue
	Queue *string `json:"queue,omitempty"`

	// List of issue keys
	// String or Array of strings
	Keys interface{} `json:"keys,omitempty"`

	// Issue filtering parameters. The parameter can specify any field and value to filter by.
	Filter map[string]interface{} `json:"filter,omitempty"`

	// Filter using the query language
	// https://cloud.yandex.ru/en/docs/tracker/user/query-filter
	Query *string `json:"query,omitempty"`
}

type Issue added in v1.0.4

type Issue struct {
	// Address of the API resource with information about the issue.
	Self string `json:"self"`

	// Issue ID.
	ID string `json:"id"`

	// Issue key.
	Key string `json:"key"`

	// Issue version. Each change to the issue parameters increases its version number.
	Version int `json:"version"`

	// Date and time when the last comment was added.
	LastCommentUpdatedAt string `json:"lastCommentUpdatedAt"`

	// Issue name.
	Summary string `json:"summary"`

	// Object with information about the parent issue.
	Parent *BasicIssue `json:"parent"`

	// Array with information about alternative issue keys.
	Aliases []string `json:"aliases"`

	// 	Object with information about the employee who edited the issue last.
	UpdatedBy *BasicUser `json:"updatedBy"`

	// Issue description.
	Description string `json:"description"`

	// Array of objects with information about the sprint.
	Sprint []*BasicSprint `json:"sprint"`

	// Object with information about the issue type.
	Type *IssueType `json:"type"`

	// Object with information about the priority.
	Priority *BasicPriority `json:"priority"`

	// Issue creation date and time.
	CreatedAt string `json:"createdAt"`

	// Array of objects with information about issue followers.
	Followers []*BasicUser `json:"followers"`

	// Object with information about the user who created the issue.
	CreatedBy *BasicUser `json:"createdBy"`

	// Number of votes for the issue.
	Votes int `json:"votes"`

	// Object with information about the issue's assignee.
	Assignee *BasicUser `json:"assignee"`

	// Object with information about the issue queue.
	Queue *BasicQueue `json:"queue"`

	// Date and time when the issue was last updated.
	UpdatedAt string `json:"updatedAt"`

	// Object with information about the issue status.
	Status *BasicStatus `json:"status"`

	// Object with information about the previous status of the issue.
	PreviousStatus *BasicStatus `json:"previousStatus"`

	// Favorite issue flag:
	// true: Issue added to favorites by the user.
	// false: Issue not added to favorites.
	Favorite bool `json:"favorite"`
}

Issue structure in Yandex.Tracker https://cloud.yandex.ru/en/docs/tracker/concepts/issues/get-issue

type IssueType added in v1.0.4

type IssueType struct {
	// Address of the API resource with information about the issue type.
	Self string `json:"self"`

	// ID of the issue type.
	ID string `json:"id"`

	// Key of the issue type.
	Key string `json:"key"`

	// Issue type name displayed.
	Display string `json:"display"`
}

IssueType https://cloud.yandex.ru/en/docs/tracker/concepts/issues/get-issue#type

type ListOptions added in v1.0.4

type ListOptions struct {
	// Additional fields to be included into the response:
	// transitions: Workflow transitions between statuses
	// attachments: Attached files
	Expand string

	// Number of issues per response page. The default value is 50. To set up additional response output parameters, use pagination.
	// https://cloud.yandex.ru/en/docs/tracker/common-format#displaying-results
	PerPage int
}

type Priority added in v1.0.4

type Priority struct {
	// Address of the API resource with information about the priority.
	Self string `json:"self"`

	// Priority ID.
	ID int `json:"id"`

	// Priority key.
	Key string `json:"key"`

	// Priority version.
	Version int `json:"version"`

	// Priority name displayed.
	// If localized=false is provided in the request, this parameter duplicates the name in other languages.
	Name string `json:"name"`

	// Priority weight. This parameter affects the order of priority display in the interface.
	Order int `json:"order"`
}

Priority https://cloud.yandex.ru/en/docs/tracker/concepts/issues/get-priorities

type Ticket

type Ticket map[string]interface{}

func (Ticket) Assignee

func (t Ticket) Assignee() BasicUser

Assignee Get ticket assignee

func (Ticket) CreatedBy

func (t Ticket) CreatedBy() BasicUser

CreatedBy Get ticket author

func (Ticket) Description

func (t Ticket) Description() string

Description Get ticket description

func (Ticket) Followers

func (t Ticket) Followers() BasicUsers

Followers Get ticket followers

func (Ticket) GetField

func (t Ticket) GetField(field string) string

GetField Get any custom ticket field

func (Ticket) Key

func (t Ticket) Key() string

Key Get ticket key

func (Ticket) SlackMessageID

func (t Ticket) SlackMessageID() string

SlackMessageID Get ticket custom field slack message id

func (Ticket) Status

func (t Ticket) Status() string

Status Get ticket status

func (Ticket) Summary

func (t Ticket) Summary() string

Summary Get ticket summary

type TicketComment

type TicketComment map[string]interface{}

func (TicketComment) CreatedBy

func (t TicketComment) CreatedBy() BasicUser

CreatedBy Get comment author

func (TicketComment) GetField

func (t TicketComment) GetField(field string) string

GetField Get any custom ticket field

func (TicketComment) Summonees

func (t TicketComment) Summonees() BasicUsers

Summonees Get comment author

func (TicketComment) Text

func (t TicketComment) Text() string

Text Get comment text

type TicketComments

type TicketComments []TicketComment

func (TicketComments) GetLast

func (t TicketComments) GetLast() TicketComment

GetLast Return last comment

type User

type User struct {
	// Address of the API resource with information about the user account
	Self string `json:"self"`

	// Unique ID of the user Tracker account
	UID int `json:"uid"`

	// User's login
	Login string `json:"login"`

	// Unique ID of the user Tracker account
	TrackerUid int `json:"trackerUid"`

	// Unique ID of the user account in the Yandex 360 for Business organization and Yandex ID
	PassportUid int `json:"passportUid"`

	// User unique ID in Yandex Cloud Organization
	CloudUid string `json:"cloudUid"`

	// User's first name
	FirstName string `json:"firstName"`

	// User's last name
	LastName string `json:"lastName"`

	// Displayed user name
	Display string `json:"display"`

	// User email address
	Email string `json:"email"`

	// Service parameter
	External bool `json:"external"`

	// Flag indicating whether the user has full access to Tracker:
	// true: Full access
	// false: Read-only access
	HasLicense bool `json:"hasLicense"`

	// User status in the organization:
	// true: User is dismissed
	// false: User is a current employee
	Dismissed bool `json:"dismissed"`

	// Service parameter
	UseNewFilters bool `json:"useNewFilters"`

	// Flag indicating whether user notifications are forced disabled:
	// true: Disabled
	// false: Enabled
	DisableNotifications bool `json:"disableNotifications"`

	// Date and time of the user's first authentication, in the YYYY-MM-DDThh:mm:ss.sss±hhmm format
	FirstLoginDate string `json:"firstLoginDate"`

	// Date and time of the user's last authentication, in the YYYY-MM-DDThh:mm:ss.sss±hhmm format
	LastLoginDate string `json:"lastLoginDate"`

	// Method of adding a user:
	// true: By sending an invitation by email
	// false: By other means
	WelcomeMailSent bool `json:"welcomeMailSent"`
}

User structure in Yandex.Tracker https://cloud.yandex.ru/en/docs/tracker/get-user-info

type Users

type Users []User

Jump to

Keyboard shortcuts

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