reportportal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 9 Imported by: 0

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.

Types

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public GitHub API, but can be
	// set to a domain endpoint to use with GitHub Enterprise. BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// Services used for talking to different parts of the ReportPortal API.
	Dashboard       IDashboardService
	Widget          IWidgetService
	Filter          IFilterService
	ProjectSettings IProjectSettingsService
	// contains filtered or unexported fields
}

A Client manages communication with the ReportPortal API.

func NewClient

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

func (*Client) BareDo

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

BareDo sends an API request and lets you handle the api response. If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body.

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. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If v is nil, and no error hapens, the response is returned as is.

func (*Client) NewRequest

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

NewRequest 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. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Dashboard

type Dashboard struct {
	Owner       string            `json:"owner"`
	Share       bool              `json:"share"`
	ID          int               `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Widgets     []DashboardWidget `json:"widgets"`
}

type DashboardAddWidget

type DashboardAddWidget struct {
	AddWidget *DashboardWidget `json:"addWidget"`
}

type DashboardList

type DashboardList struct {
	Content []*Dashboard `json:"content"`
}

type DashboardNotFoundError

type DashboardNotFoundError struct {
	Message string
}

func NewDashboardNotFoundError

func NewDashboardNotFoundError(projectName, dashboardName string) *DashboardNotFoundError

func (*DashboardNotFoundError) Error

func (e *DashboardNotFoundError) Error() string

type DashboardService

type DashboardService service

func (*DashboardService) AddWidget

func (s *DashboardService) AddWidget(projectName string, dashboardID int, w *DashboardWidget) (string, *Response, error)

func (*DashboardService) Create

func (s *DashboardService) Create(projectName string, d *NewDashboard) (int, *Response, error)

func (*DashboardService) Delete

func (s *DashboardService) Delete(projectName string, id int) (string, *Response, error)

func (*DashboardService) GetByID

func (s *DashboardService) GetByID(projectName string, id int) (*Dashboard, *Response, error)

func (*DashboardService) GetByName

func (s *DashboardService) GetByName(projectName, name string) (*Dashboard, *Response, error)

func (*DashboardService) RemoveWidget added in v0.3.0

func (s *DashboardService) RemoveWidget(projectName string, dashboardID int, widgetID int) (string, *Response, error)

func (*DashboardService) Update added in v0.3.0

func (s *DashboardService) Update(projectName string, dashboardID int, d *UpdateDashboard) (string, *Response, error)

type DashboardWidget

type DashboardWidget struct {
	WidgetID       int                     `json:"widgetId"`
	Share          bool                    `json:"share"`
	WidgetName     string                  `json:"widgetName"`
	WidgetType     string                  `json:"widgetType"`
	WidgetSize     DashboardWidgetSize     `json:"widgetSize"`
	WidgetPosition DashboardWidgetPosition `json:"widgetPosition"`
}

type DashboardWidgetPosition

type DashboardWidgetPosition struct {
	PositionX int `json:"positionX"`
	PositionY int `json:"positionY"`
}

type DashboardWidgetSize

type DashboardWidgetSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type EntryCreated

type EntryCreated struct {
	ID int `json:"id"`
}

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response // HTTP response that caused this error
	ErrorCode int            `json:"errorCode"` // error code
	Message   string         `json:"message"`   // error message

	ErrorDescription string `json:"error_description"`
	ErrorS           string `json:"error"`
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Filter

type Filter struct {
	Share       bool              `json:"share"`
	ID          int               `json:"id"`
	Name        string            `json:"name"`
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Owner       string            `json:"owner"`
	Conditions  []FilterCondition `json:"conditions"`
	Orders      []FilterOrder     `json:"orders"`
}

type FilterCondition added in v0.2.0

type FilterCondition struct {
	Condition      string `json:"condition"`
	FilteringField string `json:"filteringField"`
	Value          string `json:"value"`
}

type FilterList

type FilterList struct {
	Content []*Filter `json:"content"`
}

type FilterNotFoundError

type FilterNotFoundError struct {
	Message string
}

func NewFilterNotFoundError

func NewFilterNotFoundError(projectName, filterName string) *FilterNotFoundError

func (*FilterNotFoundError) Error

func (e *FilterNotFoundError) Error() string

type FilterOrder added in v0.2.0

type FilterOrder struct {
	IsAsc         bool   `json:"isAsc"`
	SortingColumn string `json:"sortingColumn"`
}

type FilterService

type FilterService service

func (*FilterService) Create added in v0.2.0

func (s *FilterService) Create(projectName string, f *NewFilter) (int, *Response, error)

func (*FilterService) GetByID added in v0.2.0

func (s *FilterService) GetByID(projectName string, id int) (*Filter, *Response, error)

func (*FilterService) GetByName

func (s *FilterService) GetByName(projectName, name string) (*Filter, *Response, error)

func (*FilterService) Update added in v0.3.0

func (s *FilterService) Update(projectName string, id int, f *UpdateFilter) (string, *Response, error)

type IDashboardService added in v0.3.0

type IDashboardService interface {
	GetByName(projectName, name string) (*Dashboard, *Response, error)
	GetByID(projectName string, id int) (*Dashboard, *Response, error)
	Create(projectName string, d *NewDashboard) (int, *Response, error)
	Update(projectName string, dashboardID int, d *UpdateDashboard) (string, *Response, error)
	Delete(projectName string, id int) (string, *Response, error)
	AddWidget(projectName string, dashboardID int, w *DashboardWidget) (string, *Response, error)
	RemoveWidget(projectName string, dashboardID int, widgetID int) (string, *Response, error)
}

type IFilterService added in v0.3.0

type IFilterService interface {
	GetByID(projectName string, id int) (*Filter, *Response, error)
	GetByName(projectName, name string) (*Filter, *Response, error)
	Create(projectName string, f *NewFilter) (int, *Response, error)
	Update(projectName string, id int, f *UpdateFilter) (string, *Response, error)
}

type IProjectSettingsService added in v0.3.0

type IProjectSettingsService interface {
	Get(projectName string) (*ProjectSettings, *Response, error)
}

type IWidgetService added in v0.3.0

type IWidgetService interface {
	Get(projectName string, id int) (*Widget, *Response, error)
	Post(projectName string, w *NewWidget) (int, *Response, error)
}

type IssueSubType

type IssueSubType struct {
	ID        int    `json:"id"`
	Locator   string `json:"locator"`
	TypeRef   string `json:"typeRef"`
	LongName  string `json:"longName"`
	ShortName string `json:"shortName"`
	Color     string `json:"color"`
}

type IssueSubTypes added in v0.3.0

type IssueSubTypes map[string][]IssueSubType

type MockDashboardService added in v0.3.0

type MockDashboardService struct {
	GetByNameM    func(projectName, name string) (*Dashboard, *Response, error)
	GetByIDM      func(projectName string, id int) (*Dashboard, *Response, error)
	CreateM       func(projectName string, d *NewDashboard) (int, *Response, error)
	UpdateM       func(projectName string, dashboardID int, d *UpdateDashboard) (string, *Response, error)
	DeleteM       func(projectName string, id int) (string, *Response, error)
	AddWidgetM    func(projectName string, dashboardID int, w *DashboardWidget) (string, *Response, error)
	RemoveWidgetM func(projectName string, dashboardID int, widgetID int) (string, *Response, error)

	Counter MockDashboardServiceCounter
}

func (*MockDashboardService) AddWidget added in v0.3.0

func (s *MockDashboardService) AddWidget(projectName string, dashboardID int, w *DashboardWidget) (string, *Response, error)

func (*MockDashboardService) Create added in v0.3.0

func (s *MockDashboardService) Create(projectName string, d *NewDashboard) (int, *Response, error)

func (*MockDashboardService) Delete added in v0.3.0

func (s *MockDashboardService) Delete(projectName string, id int) (string, *Response, error)

func (*MockDashboardService) GetByID added in v0.3.0

func (s *MockDashboardService) GetByID(projectName string, id int) (*Dashboard, *Response, error)

func (*MockDashboardService) GetByName added in v0.3.0

func (s *MockDashboardService) GetByName(projectName, name string) (*Dashboard, *Response, error)

func (*MockDashboardService) RemoveWidget added in v0.3.0

func (s *MockDashboardService) RemoveWidget(projectName string, dashboardID int, widgetID int) (string, *Response, error)

func (*MockDashboardService) Update added in v0.3.0

func (s *MockDashboardService) Update(projectName string, dashboardID int, d *UpdateDashboard) (string, *Response, error)

type MockDashboardServiceCounter added in v0.3.0

type MockDashboardServiceCounter struct {
	GetByName    int
	GetByID      int
	Create       int
	Update       int
	Delete       int
	AddWidget    int
	RemoveWidget int
}

type MockFilterService added in v0.3.0

type MockFilterService struct {
	GetByIDM   func(projectName string, id int) (*Filter, *Response, error)
	GetByNameM func(projectName, name string) (*Filter, *Response, error)
	CreateM    func(projectName string, f *NewFilter) (int, *Response, error)
	UpdateM    func(projectName string, id int, f *UpdateFilter) (string, *Response, error)

	Counter MockFilterServiceCounter
}

func (*MockFilterService) Create added in v0.3.0

func (s *MockFilterService) Create(projectName string, f *NewFilter) (int, *Response, error)

func (*MockFilterService) GetByID added in v0.3.0

func (s *MockFilterService) GetByID(projectName string, id int) (*Filter, *Response, error)

func (*MockFilterService) GetByName added in v0.3.0

func (s *MockFilterService) GetByName(projectName, name string) (*Filter, *Response, error)

func (*MockFilterService) Update added in v0.3.0

func (s *MockFilterService) Update(projectName string, id int, f *UpdateFilter) (string, *Response, error)

type MockFilterServiceCounter added in v0.3.0

type MockFilterServiceCounter struct {
	GetByID   int
	GetByName int
	Create    int
	Update    int
}

type MockProjectSettingsService added in v0.3.0

type MockProjectSettingsService struct {
	GetM func(projectName string) (*ProjectSettings, *Response, error)

	Counter MockProjectSettingsServiceCounter
}

func (*MockProjectSettingsService) Get added in v0.3.0

type MockProjectSettingsServiceCounter added in v0.3.0

type MockProjectSettingsServiceCounter struct {
	Get int
}

type MockWidgetService added in v0.3.0

type MockWidgetService struct {
	GetM  func(projectName string, id int) (*Widget, *Response, error)
	PostM func(projectName string, w *NewWidget) (int, *Response, error)

	Counter MockWidgetServiceCounter
}

func (*MockWidgetService) Get added in v0.3.0

func (s *MockWidgetService) Get(projectName string, id int) (*Widget, *Response, error)

func (*MockWidgetService) Post added in v0.3.0

func (s *MockWidgetService) Post(projectName string, w *NewWidget) (int, *Response, error)

type MockWidgetServiceCounter added in v0.3.0

type MockWidgetServiceCounter struct {
	Get  int
	Post int
}

type NewDashboard

type NewDashboard struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Share       bool   `json:"share"`
}

type NewFilter added in v0.2.0

type NewFilter struct {
	Name        string            `json:"name"`
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Share       bool              `json:"share"`
	Conditions  []FilterCondition `json:"conditions"`
	Orders      []FilterOrder     `json:"orders"`
}

type NewWidget

type NewWidget struct {
	Name              string                  `json:"name"`
	Description       string                  `json:"description"`
	Share             bool                    `json:"share"`
	WidgetType        string                  `json:"widgetType"`
	ContentParameters WidgetContentParameters `json:"contentParameters"`
	Filters           []int                   `json:"filterIds"`
}

type OperationCompletion

type OperationCompletion struct {
	Message string `json:"message"`
}

type ProjectSettings

type ProjectSettings struct {
	ProjectID int           `json:"project"`
	SubTypes  IssueSubTypes `json:"subTypes"`
}

type ProjectSettingsService

type ProjectSettingsService service

func (*ProjectSettingsService) Get

func (s *ProjectSettingsService) Get(projectName string) (*ProjectSettings, *Response, error)

type Response

type Response struct {
	*http.Response
}

type UpdateDashboard added in v0.3.0

type UpdateDashboard struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Share       bool   `json:"share"`
}

type UpdateFilter added in v0.3.0

type UpdateFilter struct {
	Name        string            `json:"name"`
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Share       bool              `json:"share"`
	Conditions  []FilterCondition `json:"conditions"`
	Orders      []FilterOrder     `json:"orders"`
}

type Widget

type Widget struct {
	Description       string                  `json:"description"`
	Owner             string                  `json:"owner"`
	Share             bool                    `json:"share"`
	ID                int                     `json:"id"`
	Name              string                  `json:"name"`
	WidgetType        string                  `json:"widgetType"`
	ContentParameters WidgetContentParameters `json:"contentParameters"`
	AppliedFilters    []Filter                `json:"appliedFilters"`
	Content           interface{}             `json:"content"` // incomplete
}

type WidgetContentParameters

type WidgetContentParameters struct {
	ContentFields []string               `json:"contentFields"`
	ItemsCount    int                    `json:"itemsCount"`
	WidgetOptions map[string]interface{} `json:"widgetOptions"`
}

type WidgetService

type WidgetService service

func (*WidgetService) Get

func (s *WidgetService) Get(projectName string, id int) (*Widget, *Response, error)

func (*WidgetService) Post

func (s *WidgetService) Post(projectName string, w *NewWidget) (int, *Response, error)

Jump to

Keyboard shortcuts

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