api

package
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGlobalHeader added in v0.20.2

func AddGlobalHeader(name, value string)

AddGlobalHeader - adds header these headers will be added to all REST API calls.

func AddUserToOrganisation added in v0.19.0

func AddUserToOrganisation(client *Client, hostname, orgID, username string) error

func AuthHTTPClient

func AuthHTTPClient(hostname string) *http.Client

AuthHTTPClient returns an authenticated HTTP client

func CreateEntity added in v0.18.0

func CreateEntity(client *Client, hostname string, org string, entity entities.Entity) error

func CreateOrganisation added in v0.19.0

func CreateOrganisation(client *Client, hostname, orgName string) error

func CurrentSourceID added in v0.4.0

func CurrentSourceID(
	client *Client, hostname string,
	orgID string, hash string) (string, error)

CurrentSourceID looks up into the API/DB for a registered Source from the internally computed Source hash (by the CLI)

func CurrentUserID

func CurrentUserID(client *Client, hostname string) (string, error)

func CurrentUserOrganizationID

func CurrentUserOrganizationID(client *Client, hostname string) (string, error)

CurrentUserOrganizationID returns the identifier of the default organization for the current logged in user

func CurrentUsername

func CurrentUsername(client *Client, hostname string) (string, error)

func DeleteObjectives added in v0.22.0

func DeleteObjectives(client *Client, hostname string, org string, selectors []entities.Labels) error

func DeleteOrganisation added in v0.19.0

func DeleteOrganisation(client *Client, hostname, orgID string) error

func GraphFromManifest added in v0.23.1

func GraphFromManifest(client *Client, hostname, org string, m entities.Manifest) (*entities.NodeGraph, error)

func GraphV1 added in v0.23.1

func GraphV1(client *Client, hostname, org string) (*entities.NodeGraph, error)

GraphV1 - returns node graph data showing relationships between all entities within the organisation.

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

func NewHTTPClient

func NewHTTPClient(opts ...ClientOption) *http.Client

NewHTTPClient initializes an http.Client with a default timeout

func RecordSuggestions added in v0.4.0

func RecordSuggestions(client *Client, hostname string,
	orgID string, execID string, suggestions *[]*core.Suggestion) error

RecordSuggestions records on the API the suggestions for a given execution suggestions can be recorded by batch or one at a time (maybe not ideal) and will be appended on the backend side

func RemoveUserFromOrganisation added in v0.19.0

func RemoveUserFromOrganisation(client *Client, hostname, orgID, username string) error

func SendContext added in v0.4.0

func SendContext(
	client *Client, hostname string, orgID string,
	context *context.Context) (string, error)

SendContext sends the current runtime context to API

func SyncManifest added in v0.20.0

func SyncManifest(client *Client, entityHost, org string, m entities.Manifest) error

SyncManifest - synchronize objectives from manifest with the entity server

func UnsecureHTTPClient

func UnsecureHTTPClient(hostname string) *http.Client

UnsecureHTTPClient returns a non-authenticated HTTP client

Types

type Client

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

Client facilitates making HTTP requests to the Reliably API

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client

func NewClientFromHTTP

func NewClientFromHTTP(httpClient *http.Client) *Client

NewClientFromHTTP takes in an http.Client instance

func (Client) REST

func (c Client) REST(hostname string, method string, p string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

func (Client) RESTv2 added in v0.18.0

func (c Client) RESTv2(hostname string, method string, p string, body io.Reader, data interface{}) error

RESTv2 performs a REST request and parses the response. Compared to the previous version, this does not automatically use the API prefix to construct the url, only the base HTTP location of the server

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func AddHeader

func AddHeader(name, value string) ClientOption

AddHeader turns a RoundTripper into one that adds a request header

func AddHeaderFunc

func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption

AddHeaderFunc is an AddHeader that gets the string value from a function

type Execution added in v0.4.0

type Execution struct {
	ID          string       `json:"id"`
	Date        time.Time    `json:"created_on"`
	Suggestions []Suggestion `json:"suggestions"`
}

type ExpandedObjective added in v0.20.2

type ExpandedObjective struct {
	entities.Objective `json:"objective,omitempty"`
	ForEach            ForEachResponse `json:"forEach,omitempty"`
}

type ForEach added in v0.20.2

type ForEach struct {
	ObjectiveResult ObjectiveResult `json:"objectiveResult"`
}

type ForEachResponse added in v0.20.2

type ForEachResponse struct {
	ObjectiveResults []entities.ObjectiveResult `json:"objectiveResults,omitempty"`
}

type HTTPError

type HTTPError struct {
	StatusCode int
	RequestURL *url.URL
	Message    string
}

HTTPError is an error returned by a failed API call

func (HTTPError) Error

func (err HTTPError) Error() string

type NewExecution added in v0.4.0

type NewExecution struct {
	ID       string `json:"id"`
	OrgID    string `json:"org_id"`
	SourceID string `json:"source_id"`
}

func SendExecutionContext added in v0.4.0

func SendExecutionContext(
	client *Client, hostname string, orgID string,
	context *context.Context) (*NewExecution, error)

SendExecutionContext sends the current runtime context to API

type ObjectiveResult added in v0.20.2

type ObjectiveResult struct {
	Include bool `json:"include"`
	Limit   int  `json:"limit"`
}

type Organization

type Organization struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	CreatedBy string `json:"created_by"`
	Owner     string `json:"owner,omitempty"`
}

Organization represents an Organization under Reliably

func CurrentUserOrganization

func CurrentUserOrganization(client *Client, hostname string) (*Organization, error)

CurrentUserOrganization returns the default organization of the current logged in user

func GetOrganisation added in v0.19.4

func GetOrganisation(client *Client, hostname string, orgID string) (*Organization, error)

func GetOrganizationByName added in v0.19.4

func GetOrganizationByName(client *Client, hostname string, name string) (*Organization, error)

func ListOrganizations

func ListOrganizations(client *Client, hostname string) ([]Organization, error)

ListOrganizations list all organizations to which the current logged in user is a member of

type Page added in v0.4.0

type Page struct {
	Cursor      string `json:"cursor"`
	HasNextPage bool   `json:"has_next_page"`
}

type QueryBody added in v0.20.2

type QueryBody struct {
	Kind    string            `json:"kind"`
	Limit   int               `json:"limit"`
	Labels  map[string]string `json:"labels"`
	ForEach ForEach           `json:"forEach"`
}

type QueryResponse added in v0.20.2

type QueryResponse struct {
	Objectives []ExpandedObjective `json:"objectives,omitempty"`
}

func Query added in v0.20.2

func Query(client *Client, hostname string, version string, org string, query QueryBody) (*QueryResponse, error)

type Source added in v0.4.0

type Source struct {
	ID   string                 `json:"id"`
	Type string                 `json:"type"`
	Meta map[string]interface{} `json:"meta"`
}

type Suggestion added in v0.4.0

type Suggestion struct {
	ID   string           `json:"id"`
	Date time.Time        `json:"created_on"`
	Data *core.Suggestion `json:"data"`
}

type SuggestionHistory added in v0.4.0

type SuggestionHistory struct {
	PageInfo   Page        `json:"page_info"`
	Executions []Execution `json:"executions"`
}

func GetSuggestionHistory added in v0.4.0

func GetSuggestionHistory(client *Client, hostname string,
	orgID string, sourceID string, cursor string) (*SuggestionHistory, error)

type UserInfo

type UserInfo struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	FullName  string    `json:"fullname"`
	Email     string    `json:"email"`
	LastLogin time.Time `json:"last_login"`
}

func CurrentUser

func CurrentUser(client *Client, hostname string) (*UserInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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