Categorygithub.com/manuelbcd/go-openproject
modulepackage
0.1.0
Repository: https://github.com/manuelbcd/go-openproject.git
Documentation: pkg.go.dev

# README

OpenProject Go Client Library

codecov Go Report Card License: MIT

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

EndpointGET singleGET manyPOST singlePOST manyDELETE singleDELETE many
Attachments (Info):heavy_check_mark::heavy_check_mark:implementing-pending-
Attachments (Download):heavy_check_mark:-----
Categories:heavy_check_mark::heavy_check_mark:----
Documentsimplementing-----
Projects:heavy_check_mark::heavy_check_mark::heavy_check_mark:pendingpendingpending
Queries:heavy_check_mark::heavy_check_mark:--:heavy_check_mark:-
Schemaspending
Statuses:heavy_check_mark::heavy_check_mark:pendingpendingpendingpending
Users:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:pending
Wiki Pages:heavy_check_mark:pendingpendingpendingpendingpending
WorkPackages:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:

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

# Packages

No description provided by the author

# Functions

CheckResponse checks the API response for errors, and returns them if present.
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.
DeleteWithContext (generic) retrieves object (HTTP DELETE verb) obj can be any main object (attachment, user, project, work-package, etc...).
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{}.
GetWithContext (generic) retrieves object (HTTP GET verb) obj can be any main object (attachment, user, project, work-package, etc...) as well as response interface{}.
NewClient returns a new OpenProject API client.
NewOpenProjectError creates a new OpenProject Error.

# Constants

Different operator.
Equal operator.
GreaterOrEqual operator.
GreaterThan operator.
Like operator.
LowerOrEqual operator.
LowerThan operator.
SearchString operator.

# Structs

Attachment is the object representing OpenProject attachments.
AttachmentDigest wraps algorithm and hash.
AttachmentService handles attachments for the OpenProject instance / API.
AuthenticationService handles authentication for the OpenProject instance / API.
BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password.
Category wraps Work-package categories.
CategoryElements is the list of elements nested within CategoryList.
CategoryList represent a list of Projects.
CategoryService handles categories for the OpenProject instance / API.
Client manages communication with the OpenProject API.
Error message from OpenProject.
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.
OPGenericDescription is an structure widely used in several OpenProject API objects.
OptionsFields array wraps field, Operator, Value within FilterOptions.
Project structure representing OpenProject project.
ProjectService handles projects for the OpenProject instance / API.
Query is the object representing OpenProject queries.
QueryElements array of elements within a query.
QueryFilter filters within a query TODO:Complete fields ( i.e.
QueryService handles statuses from the OpenProject instance / API.
Response represents OpenProject API response.
SearchEmbeddedWP represent elements within WorkPackage list.
SearchResultProject represent a list of Projects.
SearchResultQuery represent a list of Projects.
SearchResultStatus represent a list of Statuses.
SearchResultUser is a small wrapper around the Search.
SearchResultWP is only a small wrapper around the Search.
Session represents a Session JSON response by the OpenProject API.
Status is the object representing OpenProject statuses.
StatusService handles statuses from the OpenProject instance / API.
User is the object representing OpenProject users.
UserService handles users for the OpenProject instance / API.
WikiEmbedded wraps embedded field of WikiPage.
WikiPage is the object representing OpenProject users.
WikiPageService handles wiki-pages for the OpenProject instance / API.
WikiProject wraps WikiEmbedded data.
WorkPackage represents an OpenProject ticket or issue Please note: Time and Date fields are pointers in order to avoid rendering them when not initialized.
WorkPackageService handles workpackages for the OpenProject instance / API.
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.
WPFormEmbedded represents the 'embedded' struct nested in 'form'.
WPFormLinks represents WorkPackage Form Links.
WPLinks are WorkPackage Links.
WPLinksField link and title.
WPPayload represents the 'payload' struct nested in 'form.embedded'.

# Type aliases

Date represents the Date definition of OpenProject as a time.Time of go.
ProjDescription type contains description and format.
SearchOperator represents Search operators by custom type const Doc.
Time represents the Time definition of OpenProject as a time.Time of go.
WPDescription type contains description and format.