console

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 17 Imported by: 4

Documentation

Overview

Package console provides support for HSDP Console APIs

Index

Constants

View Source
const (
	UAA     = "UAA"
	CONSOLE = "CONSOLE"
)

Constants

Variables

View Source
var (
	ErrConsoleURLCannotBeEmpty = errors.New("console base URL cannot be empty")
	ErrUAAURLCannotBeEmpty     = errors.New("UAA URL cannot be empty")
	ErrMissingRefreshToken     = errors.New("missing refresh token")
	ErrNotAuthorized           = errors.New("not authorized")
)

Exported Errors

Functions

This section is empty.

Types

type Application

type Application struct {
	Enabled      bool        `json:"enabled"`
	MaxInstances int         `json:"maxInstances"`
	MinInstances int         `json:"minInstances"`
	Name         string      `json:"name"`
	Thresholds   []Threshold `json:"thresholds,omitempty"`
}

type AutoscalersResponse

type AutoscalersResponse struct {
	Data struct {
		Applications []Application `json:"applications"`
	} `json:"data"`
	Status string `json:"status"`
	Error  Error  `json:"error,omitempty"`
}

type CFLinksResponse

type CFLinksResponse struct {
	Links struct {
		Self struct {
			Href string `json:"href"`
		} `json:"self"`
		CloudControllerV2 struct {
			Href string `json:"href"`
			Meta struct {
				Version string `json:"version"`
			} `json:"meta"`
		} `json:"cloud_controller_v2"`
		CloudControllerV3 struct {
			Href string `json:"href"`
			Meta struct {
				Version string `json:"version"`
			} `json:"meta"`
		} `json:"cloud_controller_v3"`
		NetworkPolicyV0 struct {
			Href string `json:"href"`
		} `json:"network_policy_v0"`
		NetworkPolicyV1 struct {
			Href string `json:"href"`
		} `json:"network_policy_v1"`
		Login struct {
			Href string `json:"href"`
		} `json:"login"`
		UAA struct {
			Href string `json:"href"`
		} `json:"uaa"`
		Credhub interface{} `json:"credhub"`
		Routing struct {
			Href string `json:"href"`
		} `json:"routing"`
		Logging struct {
			Href string `json:"href"`
		} `json:"logging"`
		LogCache struct {
			Href string `json:"href"`
		} `json:"log_cache"`
		LogStream struct {
			Href string `json:"href"`
		} `json:"log_stream"`
		AppSSH struct {
			Href string `json:"href"`
			Meta struct {
				HostKeyFingerprint string `json:"host_key_fingerprint"`
				OauthClient        string `json:"oauth_client"`
			} `json:"meta"`
		} `json:"app_ssh"`
	} `json:"links"`
}

type Client

type Client struct {

	// User agent used when communicating with the HSDP IAM API.
	UserAgent string

	Metrics *MetricsService

	sync.Mutex
	// contains filtered or unexported fields
}

A Client manages communication with HSDP IAM API

func NewClient

func NewClient(httpClient *http.Client, config *Config) (*Client, error)

NewClient returns a new HSDP Console API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide a valid oAuth bearer token.

func (*Client) Close

func (c *Client) Close()

Close releases allocated resources of clients

func (*Client) Expires

func (c *Client) Expires() int64

Expires returns the expiry time (Unix) of the access token

func (*Client) HttpClient

func (c *Client) HttpClient() *http.Client

Returns the http Client used for connections

func (*Client) IDToken

func (c *Client) IDToken() string

IDToken returns the ID token

func (*Client) Login

func (c *Client) Login(username, password string) error

Login logs in a user with `username` and `password`

func (*Client) RefreshToken

func (c *Client) RefreshToken() string

RefreshToken returns the refresh token

func (*Client) SetBaseConsoleURL

func (c *Client) SetBaseConsoleURL(urlStr string) error

SetBaseConsoleURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

func (*Client) SetBaseUAAURL

func (c *Client) SetBaseUAAURL(urlStr string) error

SetBaseIDMURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

func (*Client) SetToken added in v0.34.0

func (c *Client) SetToken(token string) *Client

SetToken sets the UAA token

func (*Client) SetTokens added in v0.34.0

func (c *Client) SetTokens(accessToken, refreshToken, idToken string, expiresAt int64)

SetTokens sets the tokens

func (*Client) Token

func (c *Client) Token() (*oauth2.Token, error)

Token returns the current token. It also confirms to TokenSource

func (*Client) TokenRefresh

func (c *Client) TokenRefresh() error

TokenRefresh refreshes the accessToken

func (*Client) WithLogin added in v0.27.0

func (c *Client) WithLogin(username, password string) (*Client, error)

WithLogin returns a cloned client with new login

type Config

type Config struct {
	Region         string
	BaseConsoleURL string
	UAAURL         string
	Scopes         []string
	Debug          bool
	DebugLog       string
}

Config contains the configuration of a client

type ContextKey

type ContextKey string

type Endpoint

type Endpoint string

Endpoint type

type Error added in v0.27.0

type Error struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type Group

type Group struct {
	Name  string `json:"name"`
	Rules []Rule `json:"rules"`
}

type Instance

type Instance struct {
	CreatedAt    time.Time `json:"createdAt"`
	GUID         string    `json:"guid"`
	Name         string    `json:"name"`
	Organization string    `json:"organization"`
	Space        string    `json:"space"`
}

type MetricsResponse

type MetricsResponse struct {
	Data struct {
		Instances []Instance `json:"instances"`
	} `json:"data"`
	Status string `json:"status"`
	Error  Error  `json:"error,omitempty"`
}

type MetricsService

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

func (*MetricsService) GetApplicationAutoscaler

func (c *MetricsService) GetApplicationAutoscaler(id, app string, options ...OptionFunc) (*Application, *Response, error)

GetApplicationAutoscaler looks up a specific application autoscaler settings

func (*MetricsService) GetApplicationAutoscalers

func (c *MetricsService) GetApplicationAutoscalers(id string, options ...OptionFunc) (*[]Application, *Response, error)

GetApplicationAutoscalers looks up all available autoscalers

func (*MetricsService) GetGroupedRules

func (c *MetricsService) GetGroupedRules(options ...OptionFunc) (*[]Group, *Response, error)

GetGroupedRules looks up available rules

func (*MetricsService) GetInstanceByID

func (c *MetricsService) GetInstanceByID(id string, options ...OptionFunc) (*Instance, *Response, error)

GetInstanceByID looks up an instance by ID

func (*MetricsService) GetInstances

func (c *MetricsService) GetInstances(options ...OptionFunc) (*[]Instance, *Response, error)

GetInstances looks up available instances

func (*MetricsService) GetRuleByID

func (c *MetricsService) GetRuleByID(id string, options ...OptionFunc) (*Rule, *Response, error)

GetRuleByID retrievs a rule by ID

func (*MetricsService) UpdateApplicationAutoscaler

func (c *MetricsService) UpdateApplicationAutoscaler(id string, settings Application, options ...OptionFunc) (*Application, *Response, error)

GetApplicationAutoscaler looks up a specific application autoscaler settings

type OptionFunc

type OptionFunc func(*http.Request) error

OptionFunc is the function signature function for options

type Response

type Response struct {
	*http.Response
	Error
}

Response is a HSDP Console API response. This wraps the standard http.Response returned from HSDP Console and provides convenient access to things like errors

type Rule

type Rule struct {
	Annotations struct {
		Description string `json:"description"`
		Resolved    string `json:"resolved"`
		Summary     string `json:"summary"`
	} `json:"annotations"`
	Description string `json:"description"`
	ID          string `json:"id"`
	Metric      string `json:"metric"`
	Rule        struct {
		ExtraFor []struct {
			Name         string   `json:"name"`
			Options      []string `json:"options"`
			Type         string   `json:"type"`
			VariableName string   `json:"variableName"`
		} `json:"extraFor,omitempty"`
		Extras []struct {
			Name         string   `json:"name"`
			Options      []string `json:"options"`
			Type         string   `json:"type"`
			VariableName string   `json:"variableName"`
		} `json:"extras"`
		Operators []string  `json:"operators"`
		Subject   string    `json:"subject"`
		Threshold Threshold `json:"threshold"`
	} `json:"rule"`
	Template string `json:"template"`
}

type RuleResponse

type RuleResponse struct {
	Data struct {
		Groups []Group `json:"groups"`
	} `json:"data"`
	Status string `json:"status"`
	Error  Error  `json:"error,omitempty"`
}

type Threshold added in v0.23.0

type Threshold struct {
	Default int      `json:"default,omitempty"`
	Enabled bool     `json:"enabled"`
	Max     float64  `json:"max"`
	Min     float64  `json:"min"`
	Name    string   `json:"name"`
	Type    string   `json:"type,omitempty"`
	Unit    []string `json:"unit,omitempty"`
}

Directories

Path Synopsis
metrics

Jump to

Keyboard shortcuts

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