okrforjira

package module
v0.0.0-...-0537f0e Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 9 Imported by: 0

README

okrforjira

A golang client for OKR for Jira. This client implements the API described in

Digital Toucan is a company that continuously improves OKR for Jira. Although good care has been provided to this package, it is possible that at some point the API evolves and this package becomes outdated. Finally, this package is provided to you without any guarantee. Use it at your own risk.

Install

go get github.com/grandper/okrforjira

Usage

c := okrforjira.NewClient(nil, token)

expand := []string{"TEAMS"}
resp1, err := c.ObjectivesByDate(ctx, startDate, deadline, expand)
resp2, err := c.ObjectivesByIDs(ctx, objectiveIDs, expand)
resp3, err := c.KeyResultsByDate(ctx, startDate, deadline, expand)
resp4, err := c.KeyResultsByIDs(ctx, keyResultIDs, expand)

Example

package main

import (
    "context"
    "flag"
    "fmt"
    "os"
    "time"

    "github.com/grandper/okrforjira"
)

func main() {
    token := flag.String("token", "", "token to access your OKR data")
    flag.Parse()

    ctx := context.Background()
    c := okrforjira.NewClient(nil, *token)

    startDate := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
    deadline := time.Date(2022, time.June, 30, 0, 0, 0, 0, time.UTC)
    expand := []string{"TEAMS"}
    resp, err := c.ObjectivesByDate(ctx, startDate, deadline, expand)
    if err != nil {
        fmt.Printf("failed to get objectives by date: %s\n", err.Error())
        os.Exit(1)
    }
    fmt.Printf("%#v", resp)
}

Note

okrforjir is using Go 1.18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a HTTP client to get data from the OKR for Jira app.

func NewClient

func NewClient(httpClient *http.Client, token string) *Client

NewClient creates a new OKR for Jira client. If a nil httpClient is provided, a new http.Client will be used.

func (*Client) KeyResultsByDate

func (c *Client) KeyResultsByDate(ctx context.Context, startDate, deadline time.Time, expand []string) (Response, error)

KeyResultsByDate returns a list of key results which have start date or/and due date inside specified date range.

func (*Client) KeyResultsByIDs

func (c *Client) KeyResultsByIDs(ctx context.Context, keyResultIDs, expand []string) (Response, error)

KeyResultsByIDs returns a list of key results with specified ids.

func (*Client) ObjectivesByDate

func (c *Client) ObjectivesByDate(ctx context.Context, startDate, deadline time.Time, expand []string) (Response, error)

ObjectivesByDate returns a list of objectives which have start date or/and due date inside specified date range.

func (*Client) ObjectivesByIDs

func (c *Client) ObjectivesByIDs(ctx context.Context, objectiveIDs, expand []string) (Response, error)

ObjectivesByIDs returns a list of objectives with specified ids.

func (*Client) UpdateKeyResult

func (c *Client) UpdateKeyResult(ctx context.Context, keyResultID, status string, newValue float64, description string) (Update, error)

UpdateKeyResult update the provided key result.

func (*Client) UpdateObjective

func (c *Client) UpdateObjective(ctx context.Context, objectiveID, status, description string) (Update, error)

UpdateObjective update the provided objective.

type KeyResult

type KeyResult struct {
	ID                        string             `json:"id"`
	Key                       string             `json:"key"`
	Name                      string             `json:"name"`
	Link                      string             `json:"link"`
	Description               string             `json:"description"`
	ParentObjectiveID         string             `json:"parentObjectiveId"`
	IssueIDs                  []string           `json:"issueIds"`
	OwnerAccountID            string             `json:"ownerAccountId"`
	CollaboratorAccountIds    []string           `json:"collaboratorAccountIds"`
	PercentDone               float64            `json:"percentDone"`
	Created                   time.Time          `json:"created" time_format:"okr4j_format"`
	StartDate                 time.Time          `json:"startDate" time_format:"okr4j_format"`
	Deadline                  time.Time          `json:"deadline" time_format:"okr4j_format"`
	LabelIDs                  []string           `json:"labelIds"`
	TeamIDs                   []string           `json:"teamIds"`
	PeriodAliasID             string             `json:"periodAliasId"`
	LatestUpdate              Update             `json:"latestUpdate"`
	Unit                      Unit               `json:"unit"`
	CurrentProgressDefinition ProgressDefinition `json:"currentProgressDefinition"`
	Weight                    float64            `json:"weight"`
}

type Label

type Label struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type OKR

type OKR struct {
	ID                     string    `json:"id"`
	Key                    string    `json:"key"`
	Name                   string    `json:"name"`
	Link                   string    `json:"link"`
	Description            string    `json:"description"`
	ParentObjectiveID      string    `json:"parentObjectiveId"`
	OwnerAccountID         string    `json:"ownerAccountId"`
	CollaboratorAccountIDs []string  `json:"collaboratorAccountIds"`
	PercentDone            float64   `json:"percentDone"`
	Created                time.Time `json:"created" time_format:"okr4j_format"`
	StartDate              time.Time `json:"startDate" time_format:"okr4j_format"`
	Deadline               time.Time `json:"deadline" time_format:"okr4j_format"`
	LabelIDs               []string  `json:"labelIds"`
	TeamIDs                []string  `json:"teamIds"`
	KRIDs                  []string  `json:"krIds"`
	ChildObjectiveIDs      []string  `json:"childObjectiveIds"`
	LatestUpdate           Update    `json:"latestUpdate"`
	PeriodAliasID          string    `json:"periodAliasId"`
	Weight                 float64   `json:"weight"`
}

type Period

type Period struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	StartDate time.Time `json:"startDate" time_format:"okr4j_format"`
	Deadline  time.Time `json:"deadline" time_format:"okr4j_format"`
}

type ProgressDefinition

type ProgressDefinition struct {
	Type         string  `json:"type"`
	StartValue   float64 `json:"startValue"`
	DesiredValue float64 `json:"desiredValue"`
	JQL          string  `json:"jql"`
}

type Response

type Response struct {
	OKRs       []OKR       `json:"okrs"`
	KeyResults []KeyResult `json:"krs"`
	Teams      []Team      `json:"teams"`
	Periods    []Period    `json:"periods"`
	Labels     []Label     `json:"labels"`
}

type Team

type Team struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Unit

type Unit struct {
	Name   string `json:"name"`
	Symbol string `json:"symbol"`
}

type Update

type Update struct {
	EntityID    string    `json:"entityId"`
	Status      string    `json:"status"`
	Created     time.Time `json:"created" time_format:"okr4j_format"`
	Value       float64   `json:"value"`
	Description string    `json:"description"`
}

Jump to

Keyboard shortcuts

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