hierarchy

package
v2.153.0-beta.99 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrInvalidHierarchyAPIResponse

func NewErrInvalidHierarchyAPIResponse(expectedCode, actualCode int, uri string) error

NewErrInvalidHierarchyAPIResponse construct a new ErrInvalidHierarchyAPIResponse from the values provided.

Types

type Breadcrumb struct {
	Label            string `json:"label"`
	NumberofChildren int    `json:"no_of_children,omitempty"`
	HasData          bool   `json:"has_data"`
	Links            Links  `json:"links"`
}

Breadcrumb represents a breadcrumb item in the hierarchy model

type Child

type Child struct {
	Label            string `json:"label"`
	NumberofChildren int    `json:"no_of_children,omitempty"`
	Order            *int   `json:"order,omitempty"`
	HasData          bool   `json:"has_data"`
	Links            Links  `json:"links"`
}

Child represents a child item in the hierarchy model

type Client

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

Client is a hierarchy api client which can be used to make requests to the server

func New

func New(hierarchyAPIURL string) *Client

New creates a new instance of Client with a given hierarchy api url

func NewWithHealthClient

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

NewWithHealthClient creates a new instance of Client, reusing the URL and Clienter from the provided health check client.

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls hierarchy api health endpoint and returns a check object to the caller.

func (*Client) GetChild

func (c *Client) GetChild(ctx context.Context, instanceID, name, code string) (Model, error)

GetChild returns a child of a given hierarchy and code

func (*Client) GetRoot

func (c *Client) GetRoot(ctx context.Context, instanceID, name string) (Model, error)

GetRoot returns the root hierarchy response from the hierarchy API. Returns a ErrInvalidHierarchyAPIResponse if the hierarchy API response status code is not as expected.

type ErrInvalidHierarchyAPIResponse

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

ErrInvalidHierarchyAPIResponse is returned when the hierarchy api does not respond with a valid status

func (ErrInvalidHierarchyAPIResponse) Code

Code returns the status code received from hierarchy api if an error is returned

func (ErrInvalidHierarchyAPIResponse) Error

Error should be called by the user to print out the stringified version of the error

type Link struct {
	ID  string `json:"id"`
	URL string `json:"href"`
}

Link represents a link within the hierarchy api

type Links struct {
	Self Link `json:"self"`
	Code Link `json:"code"`
}

Links represents links within the hierarchy api

type Model

type Model struct {
	Label            string       `json:"label"`
	Links            Links        `json:"links"`
	HasData          bool         `json:"has_data"`
	NumberofChildren int          `json:"number_of_children,omitempty"`
	Order            *int         `json:"order,omitempty"`
	Children         []Child      `json:"children,omitempty"`
	Breadcrumbs      []Breadcrumb `json:"breadcrumbs,omitempty"`
}

Model represents the model returned by the heirarchy api

Jump to

Keyboard shortcuts

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