client

package
v0.0.0-...-c2f071e Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: GPL-3.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	SessionCookie string = "JSESSIONID"
)

Variables

View Source
var (
	API                   = "api"
	TopologyProcessor     = "topology-processor"
	HYDRA                 = "hydra"
	AUTH                  = "auth"
	APIPath               = "/vmturbo/rest/"
	TopologyProcessorPath = "/"
	HydraPath             = "/oauth2/"
	AuthPath              = "/vmturbo/auth/"
)

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	*RESTClient
	SessionCookie *http.Cookie
	ClientId      string
	ClientSecret  string
}

APIClient connects to api service through ingress

func (*APIClient) AddTarget

func (c *APIClient) AddTarget(target *api.Target) error

AddTarget adds a target via api service

func (*APIClient) DiscoverTarget

func (c *APIClient) DiscoverTarget(uuid string) (*Result, error)

Discover a target using API This function is called by turboctl which is not being maintained

func (*APIClient) GetHydraAccessToken

func (c *APIClient) GetHydraAccessToken() (string, error)

func (*APIClient) GetJwtToken

func (c *APIClient) GetJwtToken(hydraToken string) (string, error)

type BasicAuthentication

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

type Client

type Client interface {
	AddTarget(target *api.Target) error
	DiscoverTarget(uuid string) (*Result, error)
	GetHydraAccessToken() (string, error)
	GetJwtToken(hydraToken string) (string, error)
}

type Config

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

type ConfigBuilder

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

func NewConfigBuilder

func NewConfigBuilder(serverAddress *url.URL) *ConfigBuilder

func (*ConfigBuilder) BasicAuthentication

func (cb *ConfigBuilder) BasicAuthentication(usrn, passd string) *ConfigBuilder

func (*ConfigBuilder) Create

func (cb *ConfigBuilder) Create() *Config

func (*ConfigBuilder) SetClientId

func (cb *ConfigBuilder) SetClientId(clientId string) *ConfigBuilder

func (*ConfigBuilder) SetClientSecret

func (cb *ConfigBuilder) SetClientSecret(clientSecret string) *ConfigBuilder

func (*ConfigBuilder) SetProxy

func (cb *ConfigBuilder) SetProxy(proxy string) *ConfigBuilder

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type HydraTokenBody

type HydraTokenBody struct {
	AccessToken string `json:"access_token,omitempty"`
	ExpiresIn   int    `json:"expires_in,omitempty"`
	Scope       string `json:"scope,omitempty"`
	TokenType   string `json:"token_type,omitempty"`
}

type RESTClient

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

func NewRESTClient

func NewRESTClient(client *http.Client, baseURL *url.URL, apiPath string) *RESTClient

func (*RESTClient) BasicAuthentication

func (c *RESTClient) BasicAuthentication(ba *BasicAuthentication) *RESTClient

func (*RESTClient) Delete

func (c *RESTClient) Delete() *Request

func (*RESTClient) Get

func (c *RESTClient) Get() *Request

func (*RESTClient) Post

func (c *RESTClient) Post() *Request

func (*RESTClient) Put

func (c *RESTClient) Put() *Request

func (*RESTClient) Verb

func (c *RESTClient) Verb(verb string) *Request

Built request based on http verb and authentication.

type Request

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

func NewRequest

func NewRequest(client HTTPClient, verb string, baseURL *url.URL, apiPath string) *Request

func (*Request) BasicAuthentication

func (r *Request) BasicAuthentication(basicAuth *BasicAuthentication) *Request

func (*Request) BufferData

func (r *Request) BufferData(data *bytes.Buffer) *Request

func (*Request) Data

func (r *Request) Data(data []byte) *Request

func (*Request) Do

func (r *Request) Do() (Result, error)

func (*Request) Header

func (r *Request) Header(key, value string) *Request

func (*Request) Name

func (r *Request) Name(resourceName string) *Request

func (*Request) Param

func (r *Request) Param(paramName, value string) *Request

Set parameters for the request.

func (*Request) Resource

func (r *Request) Resource(resource api.ResourceType) *Request

Set the kind of the api resource that the request is made to.

func (*Request) String

func (r *Request) String() string

func (*Request) URL

func (r *Request) URL() *url.URL

URL returns the current working URL.

type Result

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

type TPClient

type TPClient struct {
	*RESTClient
}

TPClient connects to topology processor service

func (*TPClient) AddTarget

func (c *TPClient) AddTarget(target *api.Target) error

AddTarget adds a target via topology processor service

func (*TPClient) DiscoverTarget

func (c *TPClient) DiscoverTarget(uuid string) (*Result, error)

DiscoverTarget adds a target via Topology Processor service

func (*TPClient) GetHydraAccessToken

func (c *TPClient) GetHydraAccessToken() (string, error)

func (*TPClient) GetJwtToken

func (c *TPClient) GetJwtToken(hydraToken string) (string, error)

type TurboClient

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

TurboClient manages REST clients to Turbonomic services

func NewTurboClient

func NewTurboClient(c *Config) (*TurboClient, error)

func (*TurboClient) AddTarget

func (turboClient *TurboClient) AddTarget(target *api.Target, service string) error

AddTarget adds a target via a given service

func (*TurboClient) DiscoverTarget

func (turboClient *TurboClient) DiscoverTarget(uuid, service string) (*Result, error)

AddTarget discovers a target via a given service

func (*TurboClient) GetHydraAccessToken

func (turboClient *TurboClient) GetHydraAccessToken() (string, error)

GetHydraAccessToken gets the access token from Hydra service

func (*TurboClient) GetJwtToken

func (turboClient *TurboClient) GetJwtToken(hydraToken string) (string, error)

GetJwtToken gets the JwtToken from Hydra access token

Jump to

Keyboard shortcuts

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