bcloudapi

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentID

type AgentID string

AgentID identifies an agent with its ID.

func (AgentID) Value

func (id AgentID) Value() string

type AgentIdentifier

type AgentIdentifier interface {
	Value() string
}

AgentIdentifier identifies an agent when calling the manifest rendering API

type AgentInfo

type AgentInfo struct {
	AgentName  string `json:"agent_name"`
	AgentID    string `json:"agent_id"`
	IsNewAgent bool   `json:"is_new_agent"`
}

AgentInfo contains all data to describe an agent that has been registered in Bcloud.

type AgentName

type AgentName string

AgentName identifies an agent with its name.

func (AgentName) Value

func (name AgentName) Value() string

type Client

type Client interface {
	RegisterAgent(ctx context.Context, agentName string) (*AgentInfo, error)
	Credentials(ctx context.Context, agentID string) credentials.PerRPCCredentials
	GetAgentManifest(ctx context.Context, identifier AgentIdentifier) (string, error)
}

func New

func New(clientID, clientSecret, apiAddr string, noTLS bool) Client

New creates a new ApiClient

type MockAPIServer

type MockAPIServer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MockAPIServer is used to mock the Bcloud client API

func NewMockApiSrv

func NewMockApiSrv(expectedClientID, expectedSecret, expectedAccessToken, expectedName, expectedNewAgentID string) *MockAPIServer

NewMockApiSrv creates a new MockAPIServer.

func (*MockAPIServer) GetError

func (mas *MockAPIServer) GetError() error

GetError returns any error that the server has encountered while processing requests.

func (*MockAPIServer) GetRegistrationRequests

func (mas *MockAPIServer) GetRegistrationRequests() int

GetRegistrationRequests returns the number of agent registration requests that the server has received.

func (*MockAPIServer) GetTokenRequests

func (mas *MockAPIServer) GetTokenRequests() int

GetTokenRequests returns the number of token requests that the server has received.

func (*MockAPIServer) Start

func (mas *MockAPIServer) Start() string

Start starts the mock server and returns its address.

func (*MockAPIServer) Stop

func (mas *MockAPIServer) Stop()

Stop stops the server

Jump to

Keyboard shortcuts

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