openproject

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 12 Imported by: 4

README

OpenProject Go Client Library

codecov Go Report Card

Go client library for OpenProject

API doc

https://docs.openproject.org/api

Usage examples

Single work-package request

Basic work-package retrieval (Single work-package with ID 36353 from community.openproject.org) Please check examples folder for different use-cases.

import (
	"fmt"
	openproj "github.com/manuelbcd/go-openproject"
)

func main() {
	client, _ := openproj.NewClient(nil, "https://community.openproject.org/")
	wpResponse, _, err := client.WorkPackage.Get("36353", nil)
	if err != nil {
		panic(err)
	}

	// Output specific fields from response
	fmt.Printf("\n\nSubject: %s \nDescription: %s\n\n", wpResponse.Subject, wpResponse.Description.Raw)
}
Create a work package

Create a single work package

package main

import (
	"fmt"
	"strings"

	openproj "github.com/manuelbcd/go-openproject"
)

func main() {
	client, err := openproj.NewClient(nil, "https://youropenproject.url")
	if err != nil {
		fmt.Printf("\nerror: %v\n", err)
		return
	}

	i := openproj.WorkPackage{
		Subject: "This is my test work package",
		Description: &openproj.WPDescription{
			Format: "textile",
			Raw:    "This is just a demo workpackage description",
		},
	}

	wpResponse, _, err := client.WorkPackage.Create(&i, "demo-project")
	if err != nil {
		panic(err)
	}

	// Output specific fields from response
	fmt.Printf("\n\nSubject: %s \nDescription: %s\n\n", wpResponse.Subject, wpResponse.Description.Raw)
}

Supported objects

Endpoint GET single GET many POST single POST many DELETE single DELETE many
Attachments (Info) implementing - pending -
Attachments (Download) - - - - -
Categories - - - -
Documents implementing - - - - -
Projects pending pending pending
Queries - - -
Schemas pending
Statuses pending pending pending pending
Users pending
Wiki Pages pending pending pending pending pending
WorkPackages

Thanks

Thanks Wieland, Oliver and OpenProject team for your support.

Thank you very much Andy Grunwald for the idea and your base code.

Inspired in Go Jira library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. The caller is responsible to analyze the response body.

func NewOpenProjectError

func NewOpenProjectError(resp *Response, httpError error) error

NewOpenProjectError creates a new OpenProject Error

Types

type Attachment

type Attachment struct {
	Type        string               `json:"_type,omitempty" structs:"_type,omitempty"`
	ID          int                  `json:"id,omitempty" structs:"id,omitempty"`
	FileName    string               `json:"filename,omitempty" structs:"filename,omitempty"`
	FileSize    int                  `json:"filesize,omitempty" structs:"filesize,omitempty"`
	Description OPGenericDescription `json:"description,omitempty" structs:"description,omitempty"`
	ContentType string               `json:"contentType,omitempty" structs:"contentType,omitempty"`
	Digest      AttachmentDigest     `json:"digest,omitempty" structs:"digest,omitempty"`
}

Attachment is the object representing OpenProject attachments. TODO: Complete fields and complex fields (user, links, downloadlocation, container...)

type AttachmentDigest

type AttachmentDigest struct {
	Algorithm string `json:"algorithm,omitempty" structs:"algorithm,omitempty"`
	Hash      string `json:"hash,omitempty" structs:"hash,omitempty"`
}

AttachmentDigest wraps algorithm and hash

type AttachmentService

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

AttachmentService handles attachments for the OpenProject instance / API.

func (*AttachmentService) Download

func (s *AttachmentService) Download(attachmentID string) (*[]byte, error)

Download wraps DownloadWithContext using the background context.

func (*AttachmentService) DownloadWithContext

func (s *AttachmentService) DownloadWithContext(ctx context.Context, attachmentID string) (*[]byte, error)

DownloadWithContext downloads a file from attachment using attachment ID

func (*AttachmentService) Get

func (s *AttachmentService) Get(attachmentID string) (*Attachment, *Response, error)

Get wraps GetWithContext using the background context.

func (*AttachmentService) GetWithContext

func (s *AttachmentService) GetWithContext(ctx context.Context, attachmentID string) (*Attachment, *Response, error)

GetWithContext gets a wiki page from OpenProject using its ID

type AuthenticationService

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

AuthenticationService handles authentication for the OpenProject instance / API.

func (*AuthenticationService) AcquireSessionCookie

func (s *AuthenticationService) AcquireSessionCookie(username, password string) (bool, error)

AcquireSessionCookie wraps AcquireSessionCookieWithContext using the background context. Deprecated: Use CookieAuthTransport instead

func (*AuthenticationService) AcquireSessionCookieWithContext

func (s *AuthenticationService) AcquireSessionCookieWithContext(ctx context.Context, username, password string) (bool, error)

AcquireSessionCookieWithContext creates a new session for a user in OpenProject. Once a session has been successfully created it can be used to access any of OpenProject's remote APIs and also the web UI by passing the appropriate HTTP Cookie header. The header will by automatically applied to every API request. Note that it is generally preferable to use HTTP BASIC authentication with the REST API. Deprecated: Use CookieAuthTransport instead

func (*AuthenticationService) Authenticated

func (s *AuthenticationService) Authenticated() bool

Authenticated reports if the current Client has authentication details for OpenProject

func (*AuthenticationService) GetCurrentUser

func (s *AuthenticationService) GetCurrentUser() (*Session, error)

GetCurrentUser wraps GetCurrentUserWithContext using the background context.

func (*AuthenticationService) GetCurrentUserWithContext

func (s *AuthenticationService) GetCurrentUserWithContext(ctx context.Context) (*Session, error)

GetCurrentUserWithContext gets the details of the current user.

func (*AuthenticationService) SetBasicAuth

func (s *AuthenticationService) SetBasicAuth(username, password string)

SetBasicAuth sets username and password for the basic auth against the OpenProject instance. Deprecated: Use BasicAuthTransport instead

type BasicAuthTransport

type BasicAuthTransport struct {
	Username string
	Password string

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password.

func (*BasicAuthTransport) Client

func (t *BasicAuthTransport) Client() *http.Client

Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication. This is a nice little bit of sugar so we can just get the client instead of creating the client in the calling code. If it's necessary to send more information on client init, the calling code can always skip this and set the transport itself.

func (*BasicAuthTransport) RoundTrip

func (t *BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface. We just add the basic auth and return the RoundTripper for this transport type.

type Category

type Category struct {
	Type string `json:"_type,omitempty" structs:"_type,omitempty"`
	ID   int    `json:"id,omitempty" structs:"id,omitempty"`
	Name string `json:"name,omitempty" structs:"name,omitempty"`
}

Category wraps Work-package categories

type CategoryElements

type CategoryElements struct {
	Elements []Category `json:"elements,omitempty" structs:"elements,omitempty"`
}

CategoryElements is the list of elements nested within CategoryList

type CategoryList

type CategoryList struct {
	Embedded CategoryElements `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
}

CategoryList represent a list of Projects

type CategoryService

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

CategoryService handles categories for the OpenProject instance / API.

func (*CategoryService) Get

func (s *CategoryService) Get(categoryID string) (*Category, *Response, error)

Get wraps GetWithContext using the background context.

func (*CategoryService) GetList

func (s *CategoryService) GetList(projectID string) (*CategoryList, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*CategoryService) GetListWithContext

func (s *CategoryService) GetListWithContext(ctx context.Context, projectID string) (*CategoryList, *Response, error)

GetListWithContext retrieve category list from project with context

func (*CategoryService) GetWithContext

func (s *CategoryService) GetWithContext(ctx context.Context, categoryID string) (*Category, *Response, error)

GetWithContext returns a single category for the given category ID.

type Client

type Client struct {

	// Services used for talking to different parts of OpenProject API.
	Authentication *AuthenticationService
	WorkPackage    *WorkPackageService
	Project        *ProjectService
	User           *UserService
	Status         *StatusService
	WikiPage       *WikiPageService
	Attachment     *AttachmentService
	Category       *CategoryService
	Query          *QueryService
	// contains filtered or unexported fields
}

Client manages communication with the OpenProject API.

func NewClient

func NewClient(httpClient httpClient, baseURL string) (*Client, error)

NewClient returns a new OpenProject API client. If a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) Download

func (c *Client) Download(req *http.Request) (*http.Response, error)

Download request a file download

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() url.URL

GetBaseURL will return you the Base URL. This is the same URL as in the NewClient constructor

func (*Client) NewMultiPartRequest

func (c *Client) NewMultiPartRequest(method, urlStr string, buf *bytes.Buffer) (*http.Request, error)

NewMultiPartRequest wraps NewMultiPartRequestWithContext using the background context.

func (*Client) NewMultiPartRequestWithContext

func (c *Client) NewMultiPartRequestWithContext(ctx context.Context, method, urlStr string, buf *bytes.Buffer) (*http.Request, error)

NewMultiPartRequestWithContext creates an API request including a multi-part file. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. If specified, the value pointed to by buf is a multipart form.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest wraps NewRequestWithContext using the background context.

func (*Client) NewRequestWithContext

func (c *Client) NewRequestWithContext(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequestWithContext creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Date

type Date time.Time

Date represents the Date definition of OpenProject as a time.Time of go

func (Date) MarshalJSON

func (t Date) MarshalJSON() ([]byte, error)

MarshalJSON will transform the Date object into a short date string as OpenProject expects during the creation of a OpenProject request

func (*Date) UnmarshalJSON

func (t *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON will transform the OpenProject date into a time.Time during the transformation of the OpenProject JSON response

type Error

type Error struct {
	HTTPError     error
	ErrorMessages []string          `json:"errorMessages"`
	Errors        map[string]string `json:"errors"`
}

Error message from OpenProject

func (*Error) Error

func (e *Error) Error() string

Error is a short string representing the error

func (*Error) LongError

func (e *Error) LongError() string

LongError is a full representation of the error as a string

type FilterOptions

type FilterOptions struct {
	Fields []OptionsFields
}

FilterOptions allows you to specify search parameters for the get-workpackage action When used they will be converted to GET parameters within the URL Up to now OpenProject only allows "AND" combinations. "OR" combinations feature is under development, tracked by this ticket https://community.openproject.org/projects/openproject/work_packages/26837/activity More information about filters https://docs.openproject.org/api/filters/

type OPGenericDescription

type OPGenericDescription struct {
	Format string `json:"format,omitempty" structs:"format,omitempty"`
	Raw    string `json:"raw,omitempty" structs:"raw,omitempty"`
	HTML   string `json:"html,omitempty" structs:"html,omitempty"`
}

OPGenericDescription is an structure widely used in several OpenProject API objects

type OptionsFields

type OptionsFields struct {
	Field    string
	Operator SearchOperator
	Value    string
}

OptionsFields array wraps field, Operator, Value within FilterOptions

type ProjDescription

type ProjDescription OPGenericDescription

ProjDescription type contains description and format

type Project

type Project struct {
	Type        string           `json:"_type,omitempty" structs:"_type,omitempty"`
	ID          int              `json:"id,omitempty" structs:"id,omitempty"`
	Identifier  string           `json:"identifier,omitempty" structs:"identifier,omitempty"`
	Name        string           `json:"name,omitempty" structs:"name,omitempty"`
	Active      bool             `json:"active,omitempty" structs:"active,omitempty"`
	Public      bool             `json:"public,omitempty" structs:"public,omitempty"`
	Description *ProjDescription `json:"description,omitempty" structs:"description,omitempty"`
	CreatedAt   *Time            `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt   *Time            `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	Status      string           `json:"status,omitempty" structs:"status,omitempty"`
}

Project structure representing OpenProject project

type ProjectService

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

ProjectService handles projects for the OpenProject instance / API.

func (*ProjectService) Create

func (s *ProjectService) Create(project *Project) (*Project, *Response, error)

Create wraps CreateWithContext using the background context.

func (*ProjectService) CreateWithContext

func (s *ProjectService) CreateWithContext(ctx context.Context, project *Project) (*Project, *Response, error)

CreateWithContext creates a project from a JSON representation.

func (*ProjectService) Get

func (s *ProjectService) Get(projectID string) (*Project, *Response, error)

Get wraps GetWithContext using the background context.

func (*ProjectService) GetList

func (s *ProjectService) GetList() (*SearchResultProject, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*ProjectService) GetListWithContext

func (s *ProjectService) GetListWithContext(ctx context.Context) (*SearchResultProject, *Response, error)

GetListWithContext retrieve project list with context TODO: Implement search options

func (*ProjectService) GetWithContext

func (s *ProjectService) GetWithContext(ctx context.Context, projectID string) (*Project, *Response, error)

GetWithContext returns a single project for the given project key.

type Query

type Query struct {
	Type      string        `json:"_type,omitempty" structs:"_type,omitempty"`
	Starred   bool          `json:"starred,omitempty" structs:"starred,omitempty"`
	ID        int           `json:"id,omitempty" structs:"id,omitempty"`
	Name      string        `json:"name,omitempty" structs:"name,omitempty"`
	CreatedAt *Time         `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt *Time         `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	Filters   []QueryFilter `json:"filters,omitempty" structs:"filters,omitempty"`
	Sums      bool          `json:"sums,omitempty" structs:"sums,omitempty"`
	Public    bool          `json:"public,omitempty" structs:"public,omitempty"`
	Hidden    bool          `json:"hidden,omitempty" structs:"hidden,omitempty"`
}

Query is the object representing OpenProject queries. TODO: Complete fields (i.e. timelineVisible, showHierarchies, timelineZoomLevel, showHierarchies, etc...

type QueryElements

type QueryElements struct {
	Elements []Status `json:"elements,omitempty" structs:"elements,omitempty"`
}

QueryElements array of elements within a query

type QueryFilter

type QueryFilter struct {
	Type string `json:"_type,omitempty" structs:"_type,omitempty"`
	Name string `json:"name,omitempty" structs:"name,omitempty"`
}

QueryFilter filters within a query TODO:Complete fields ( i.e. _links)

type QueryService

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

QueryService handles statuses from the OpenProject instance / API.

func (*QueryService) Delete

func (s *QueryService) Delete(queryID string) (*Response, error)

Delete wraps DeleteWithContext using the background context.

func (*QueryService) DeleteWithContext

func (s *QueryService) DeleteWithContext(ctx context.Context, queryID string) (*Response, error)

DeleteWithContext will delete a single query object

func (*QueryService) Get

func (s *QueryService) Get(queryID string) (*Query, *Response, error)

Get wraps GetWithContext using the background context.

func (*QueryService) GetList

func (s *QueryService) GetList() (*SearchResultQuery, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*QueryService) GetListWithContext

func (s *QueryService) GetListWithContext(ctx context.Context) (*SearchResultQuery, *Response, error)

GetListWithContext Retrieve status list with context TODO: Implement search parameters-options

func (*QueryService) GetWithContext

func (s *QueryService) GetWithContext(ctx context.Context, queryID string) (*Query, *Response, error)

GetWithContext gets query info from OpenProject using its query ID

type Response

type Response struct {
	*http.Response
	Total    int
	Count    int
	PageSize int
	Offset   int
}

Response represents OpenProject API response. It wraps http.Response returned from API and provides information about paging.

func CreateWithContext

func CreateWithContext(ctx context.Context, objService interface{}, apiEndPoint string) (interface{}, *Response, error)

CreateWithContext (generic) creates an instance af an object (HTTP POST verb) Return the instance of the object rendered into proper struct as interface{} to be cast in the caller

func DeleteWithContext

func DeleteWithContext(ctx context.Context, objService interface{}, apiEndPoint string) (*Response, error)

DeleteWithContext (generic) retrieves object (HTTP DELETE verb) obj can be any main object (attachment, user, project, work-package, etc...)

func GetListWithContext

func GetListWithContext(ctx context.Context, objService interface{}, apiEndPoint string, options *FilterOptions) (interface{}, *Response, error)

GetListWithContext (generic) retrieves list of objects (HTTP GET verb) obj list is a collection of any main object (attachment, user, project, work-package, etc...) as well as response interface{}

func GetWithContext

func GetWithContext(ctx context.Context, objService interface{}, apiEndPoint string) (interface{}, *Response, error)

GetWithContext (generic) retrieves object (HTTP GET verb) obj can be any main object (attachment, user, project, work-package, etc...) as well as response interface{}

type SearchEmbeddedWP

type SearchEmbeddedWP struct {
	Elements []WorkPackage `json:"elements" structs:"elements"`
}

SearchEmbeddedWP represent elements within WorkPackage list

type SearchOperator

type SearchOperator string

SearchOperator represents Search operators by custom type const Doc. https://docs.openproject.org/api/filters/#header-available-filters-1

const (
	// Equal operator
	Equal SearchOperator = "="
	// Different operator
	Different SearchOperator = "<>"
	// GreaterThan operator
	GreaterThan SearchOperator = ">"
	// LowerThan operator
	LowerThan SearchOperator = "<"
	// SearchString operator
	SearchString SearchOperator = "**"
	// Like operator
	Like SearchOperator = "~"
	// GreaterOrEqual operator
	GreaterOrEqual SearchOperator = ">="
	// LowerOrEqual operator
	LowerOrEqual SearchOperator = "<="
)

type SearchResultProject

type SearchResultProject struct {
	Embedded projectElements `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
	Total    int             `json:"total" structs:"total"`
	Count    int             `json:"count" structs:"count"`
	PageSize int             `json:"pageSize" structs:"pageSize"`
	Offset   int             `json:"offset" structs:"offset"`
}

SearchResultProject represent a list of Projects

type SearchResultQuery

type SearchResultQuery struct {
	Embedded statusElements `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
	Total    int            `json:"total" structs:"total"`
	Count    int            `json:"count" structs:"count"`
	PageSize int            `json:"pageSize" structs:"pageSize"`
	Offset   int            `json:"offset" structs:"offset"`
}

SearchResultQuery represent a list of Projects

type SearchResultStatus

type SearchResultStatus struct {
	Embedded statusElements `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
	Total    int            `json:"total" structs:"total"`
	Count    int            `json:"count" structs:"count"`
	PageSize int            `json:"pageSize" structs:"pageSize"`
	Offset   int            `json:"offset" structs:"offset"`
}

SearchResultStatus represent a list of Statuses

type SearchResultUser

type SearchResultUser struct {
	Embedded searchEmbeddedUser `json:"_embedded" structs:"_embedded"`
	Total    int                `json:"total" structs:"total"`
	Count    int                `json:"count" structs:"count"`
	PageSize int                `json:"pageSize" structs:"pageSize"`
	Offset   int                `json:"offset" structs:"offset"`
}

SearchResultUser is a small wrapper around the Search

type SearchResultWP

type SearchResultWP struct {
	Embedded SearchEmbeddedWP `json:"_embedded" structs:"_embedded"`
	Total    int              `json:"total" structs:"total"`
	Count    int              `json:"count" structs:"count"`
	PageSize int              `json:"pageSize" structs:"pageSize"`
	Offset   int              `json:"offset" structs:"offset"`
}

SearchResultWP is only a small wrapper around the Search

type Session

type Session struct {
	Self    string `json:"self,omitempty"`
	Name    string `json:"name,omitempty"`
	Session struct {
		Name  string `json:"name"`
		Value string `json:"value"`
	} `json:"session,omitempty"`
	LoginInfo struct {
		FailedLoginCount    int    `json:"failedLoginCount"`
		LoginCount          int    `json:"loginCount"`
		LastFailedLoginTime string `json:"lastFailedLoginTime"`
		PreviousLoginTime   string `json:"previousLoginTime"`
	} `json:"loginInfo"`
	Cookies []*http.Cookie
}

Session represents a Session JSON response by the OpenProject API.

type Status

type Status struct {
	Type       string `json:"_type,omitempty" structs:"_type,omitempty"`
	ID         int    `json:"id,omitempty" structs:"id,omitempty"`
	Name       string `json:"name,omitempty" structs:"name,omitempty"`
	IsClosed   bool   `json:"isClosed,omitempty" structs:"isClosed,omitempty"`
	Color      string `json:"color,omitempty" structs:"color,omitempty"`
	IsDefault  bool   `json:"isDefault,omitempty" structs:"isDefault,omitempty"`
	IsReadOnly bool   `json:"isReadOnly,omitempty" structs:"isReadOnly,omitempty"`
	Position   int    `json:"position,omitempty" structs:"position,omitempty"`
}

Status is the object representing OpenProject statuses. TODO: Complete fields (add defaultDoneRatio, _links, ...)

type StatusService

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

StatusService handles statuses from the OpenProject instance / API.

func (*StatusService) Get

func (s *StatusService) Get(statusID string) (*Status, *Response, error)

Get wraps GetWithContext using the background context.

func (*StatusService) GetList

func (s *StatusService) GetList() (*SearchResultStatus, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*StatusService) GetListWithContext

func (s *StatusService) GetListWithContext(ctx context.Context) (*SearchResultStatus, *Response, error)

GetListWithContext Retrieve status list with context TODO: Implement search parameters-options

func (*StatusService) GetWithContext

func (s *StatusService) GetWithContext(ctx context.Context, statusID string) (*Status, *Response, error)

GetWithContext gets statuses info from OpenProject using its status ID TODO: Implement GetList and adapt tests

type Time

type Time time.Time

Time represents the Time definition of OpenProject as a time.Time of go

func (Time) Equal

func (t Time) Equal(u Time) bool

Equal compares time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON will transform the time.Time into a OpenProject time during the creation of a OpenProject request

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON will transform the OpenProject time into a time.Time during the transformation of the OpenProject JSON response

type User

type User struct {
	Type      string `json:"_type,omitempty" structs:"_type,omitempty"`
	ID        int    `json:"id,omitempty" structs:"id,omitempty"`
	Name      string `json:"name,omitempty" structs:"name,omitempty"`
	CreatedAt *Time  `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt *Time  `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	Login     string `json:"login,omitempty" structs:"login,omitempty"`
	Admin     bool   `json:"admin,omitempty" structs:"admin,omitempty"`
	FirstName string `json:"firstName,omitempty" structs:"firstName,omitempty"`

	Email    string `json:"email,omitempty" structs:"email,omitempty"`
	Avatar   string `json:"avatar,omitempty" structs:"avatar,omitempty"`
	Status   string `json:"status,omitempty" structs:"status,omitempty"`
	Language string `json:"language,omitempty" structs:"language,omitempty"`
	Password string `json:"password,omitempty" structs:"password,omitempty"`
	// contains filtered or unexported fields
}

User is the object representing OpenProject users. TODO: Complete object with fields identityUrl, language, _links

type UserService

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

UserService handles users for the OpenProject instance / API.

func (*UserService) Create

func (s *UserService) Create(user *User) (*User, *Response, error)

Create wraps CreateWithContext using the background context.

func (*UserService) CreateWithContext

func (s *UserService) CreateWithContext(ctx context.Context, user *User) (*User, *Response, error)

CreateWithContext creates a user from a JSON representation.

func (*UserService) Delete

func (s *UserService) Delete(userID string) (*Response, error)

Delete wraps DeleteWithContext using the background context.

func (*UserService) DeleteWithContext

func (s *UserService) DeleteWithContext(ctx context.Context, userID string) (*Response, error)

DeleteWithContext will delete a single user.

func (*UserService) Get

func (s *UserService) Get(accountID string) (*User, *Response, error)

Get wraps GetWithContext using the background context.

func (*UserService) GetList

func (s *UserService) GetList(options *FilterOptions) (*SearchResultUser, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*UserService) GetListWithContext

func (s *UserService) GetListWithContext(ctx context.Context, options *FilterOptions) (*SearchResultUser, *Response, error)

GetListWithContext will retrieve a list of users using filters

func (*UserService) GetWithContext

func (s *UserService) GetWithContext(ctx context.Context, accountID string) (*User, *Response, error)

GetWithContext gets user info from OpenProject using its Account ID TODO: Implement GetList and adapt tests

type WPDescription

type WPDescription OPGenericDescription

WPDescription type contains description and format

type WPForm

type WPForm struct {
	Type     string         `json:"_type,omitempty" structs:"_type,omitempty"`
	Embedded WPFormEmbedded `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
	Links    WPFormLinks    `json:"_links,omitempty" structs:"_links,omitempty"`
}

WPForm represents WorkPackage form OpenProject API v3 provides a WorkPackage form to get a template of work-packages dynamically A "Form" endpoint is available for that purpose.

type WPFormEmbedded

type WPFormEmbedded struct {
	Payload WPPayload `json:"payload,omitempty" structs:"payload,omitempty"`
}

WPFormEmbedded represents the 'embedded' struct nested in 'form'

type WPFormLinks struct {
}

WPFormLinks represents WorkPackage Form Links

type WPLinks struct {
	Self     WPLinksField `json:"self,omitempty" structs:"self,omitempty"`
	Type     WPLinksField `json:"type,omitempty" structs:"type,omitempty"`
	Priority WPLinksField `json:"priority,omitempty" structs:"priority,omitempty"`
	Status   WPLinksField `json:"status,omitempty" structs:"status,omitempty"`
}

WPLinks are WorkPackage Links

type WPLinksField

type WPLinksField struct {
	Href  string
	Title string
}

WPLinksField link and title

type WPPayload

type WPPayload struct {
	Subject string `json:"subject,omitempty" structs:"subject,omitempty"`

	StartDate string `json:"startDate,omitempty" structs:"startDate,omitempty"`
}

WPPayload represents the 'payload' struct nested in 'form.embedded'

type WikiEmbedded

type WikiEmbedded struct {
	Project WikiProject `json:"project,omitempty" structs:"project,omitempty"`
}

WikiEmbedded wraps embedded field of WikiPage

type WikiPage

type WikiPage struct {
	Type     string       `json:"_type,omitempty" structs:"_type,omitempty"`
	ID       int          `json:"id,omitempty" structs:"id,omitempty"`
	Title    string       `json:"title,omitempty" structs:"title,omitempty"`
	Embedded WikiEmbedded `json:"_embedded,omitempty" structs:"_embedded,omitempty"`
}

WikiPage is the object representing OpenProject users. TODO: Complete fields and complex fields (_embedded.attachments, links, project, ...)

type WikiPageService

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

WikiPageService handles wiki-pages for the OpenProject instance / API.

func (*WikiPageService) Get

func (s *WikiPageService) Get(wikiID string) (*WikiPage, *Response, error)

Get wraps GetWithContext using the background context.

func (*WikiPageService) GetWithContext

func (s *WikiPageService) GetWithContext(ctx context.Context, wikiID string) (*WikiPage, *Response, error)

GetWithContext gets a wiki page from OpenProject using its ID

type WikiProject

type WikiProject struct {
	Type       string `json:"_type,omitempty" structs:"_type,omitempty"`
	ID         int    `json:"id,omitempty" structs:"id,omitempty"`
	Identifier string `json:"identifier,omitempty" structs:"identifier,omitempty"`
	CreatedAt  *Time  `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt  *Time  `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	Status     string `json:"status,omitempty" structs:"status,omitempty"`
}

WikiProject wraps WikiEmbedded data

type WorkPackage

type WorkPackage struct {
	Subject     string                `json:"subject,omitempty" structs:"subject,omitempty"`
	Description *WPDescription        `json:"description,omitempty" structs:"description,omitempty"`
	Type        string                `json:"_type,omitempty" structs:"_type,omitempty"`
	ID          int                   `json:"id,omitempty" structs:"id,omitempty"`
	CreatedAt   *Time                 `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt   *Time                 `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	StartDate   *Date                 `json:"startDate,omitempty" structs:"startDate,omitempty"`
	DueDate     *Date                 `json:"dueDate,omitempty" structs:"dueDate,omitempty"`
	LockVersion int                   `json:"lockVersion,omitempty" structs:"lockVersion,omitempty"`
	Position    int                   `json:"position,omitempty" structs:"position,omitempty"`
	Custom      tcontainer.MarshalMap `json:"custom,omitempty" structs:"custom,omitempty"`

	Links *WPLinks `json:"_links,omitempty" _links:"id,omitempty"`
}

WorkPackage represents an OpenProject ticket or issue Please note: Time and Date fields are pointers in order to avoid rendering them when not initialized

type WorkPackageService

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

WorkPackageService handles workpackages for the OpenProject instance / API.

func (*WorkPackageService) Create

func (s *WorkPackageService) Create(workPackage *WorkPackage, projectName string) (*WorkPackage, *Response, error)

Create wraps CreateWithContext using the background context.

func (*WorkPackageService) CreateWithContext

func (s *WorkPackageService) CreateWithContext(ctx context.Context, projectName string) (*WorkPackage, *Response, error)

CreateWithContext creates a work-package or a sub-task from a JSON representation.

func (*WorkPackageService) Delete

func (s *WorkPackageService) Delete(workpackageID string) (*Response, error)

Delete wraps DeleteWithContext using the background context.

func (*WorkPackageService) DeleteWithContext

func (s *WorkPackageService) DeleteWithContext(ctx context.Context, workpackageID string) (*Response, error)

DeleteWithContext will delete a single work-package.

func (*WorkPackageService) Get

func (s *WorkPackageService) Get(workpackageID string) (*WorkPackage, *Response, error)

Get wraps GetWithContext using the background context.

func (*WorkPackageService) GetList

func (s *WorkPackageService) GetList(options *FilterOptions) ([]WorkPackage, *Response, error)

GetList wraps GetListWithContext using the background context.

func (*WorkPackageService) GetListWithContext

func (s *WorkPackageService) GetListWithContext(ctx context.Context, options *FilterOptions) ([]WorkPackage, *Response, error)

GetListWithContext will retrieve a list of work-packages using filters

func (*WorkPackageService) GetWithContext

func (s *WorkPackageService) GetWithContext(ctx context.Context, workpackageID string) (*WorkPackage, *Response, error)

GetWithContext returns a full representation of the issue for the given OpenProject key. The given options will be appended to the query string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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