connector

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCallbackAlreadyResolved = errors.New("Callback Already Resolved")

ErrCallbackAlreadyResolved represents an error which occurs if the callback has already been resolved

View Source
var ErrCallbackNotFound = errors.New("Callback Not Found")

ErrCallbackNotFound represents an error which occurs if a callback does not exist

View Source
var ErrResourceNotFound = errors.New("Resource Not Found")

ErrResourceNotFound represents an error which occurrs if the resource does not exist

Functions

func ErrorHandler

func ErrorHandler(c *FakeConnector) *bone.Mux

ErrorHandler is a set of endpoints that just returns errors. This is to test how the providers handle errors from our end.

func ValidHandler

func ValidHandler(c *FakeConnector) *bone.Mux

ValidHandler returns a set of endpoints that are valid and in use by the production connector.

Types

type AccessToken

type AccessToken struct {
	ID          manifold.ID `json:"-"`
	AccessToken string      `json:"access_token"`
	ExpiresIn   int         `json:"expires_in"`
	TokenType   string      `json:"token_type"`
	GrantType   GrantType   `json:"-"`
}

AccessToken represents an access token granted by the fake connector for kicking off the oauth flow

type AuthorizationCode

type AuthorizationCode struct {
	Code      string
	ExpiresAt time.Time
}

AuthorizationCode represents a code granted by the fake connector for kicking off the oauth flow

type Callback

type Callback struct {
	ID          manifold.ID       `json:"id"`
	Mutex       *sync.Mutex       `json:"-"`
	Type        CallbackType      `json:"type"`
	State       CallbackState     `json:"state"`
	Message     string            `json:"message"`
	Credentials map[string]string `json:"-"`
}

Callback represents a callback that is either pending or has been received from a provider

type CallbackRequest

type CallbackRequest struct {
	State       CallbackState     `json:"state"`
	Message     string            `json:"message"`
	Credentials map[string]string `json:"credentials"`
}

CallbackRequest represents a received callback from a provider

type CallbackState

type CallbackState string

CallbackState represents a state reported by the provider regarding an operation

var (
	PendingCallbackState CallbackState = "pending"
	DoneCallbackState    CallbackState = "done"
	ErrorCallbackState   CallbackState = "error"
)

PendingCallbackState represents a callback which is pending (not resolved)

type CallbackType

type CallbackType string

CallbackType represents a type of callback

var (
	ResourceProvisionCallback     CallbackType = "resource:provision"
	CredentialProvisionCallback   CallbackType = "credential:provision"
	ResourceDeprovisionCallback   CallbackType = "resource:deprovision"
	CredentialDeprovisionCallback CallbackType = "credential:deprovision"
	ResourceResizeCallback        CallbackType = "resource:resize"
)

ResourceProvisionCallback represents a callback related to a resource provision

type CreateAccessTokenJson added in v0.13.0

type CreateAccessTokenJson struct {
	GrantType    string `json:"grant_type"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

type FakeConnector

type FakeConnector struct {
	Config     *FakeConnectorConfig
	OnCallback chan *Callback

	Server *http.Server
	// contains filtered or unexported fields
}

FakeConnector represents a fake connector api server run by Grafton for use by providers to integrate with Manifold.

func New

func New(port uint, clientID string, clientSecret string, product string) (*FakeConnector, error)

New creates and configures a FakeConnector

func (*FakeConnector) AddCallback

func (c *FakeConnector) AddCallback(t CallbackType) (*Callback, error)

AddCallback stores the callback inside the FakeConnector

func (*FakeConnector) AddResource

func (c *FakeConnector) AddResource(r *Resource)

AddResource stores a resource inside the connector

func (*FakeConnector) CreateCode

func (c *FakeConnector) CreateCode() (*AuthorizationCode, error)

CreateCode returns an AuthorizationCode method

func (*FakeConnector) GetCallback

func (c *FakeConnector) GetCallback(ID manifold.ID) *Callback

GetCallback returns a callback for the given id if it exists

func (*FakeConnector) GetCapturer

func (c *FakeConnector) GetCapturer(route string) (*RequestCapturer, error)

GetCapturer returns a RequestCapturer for the given route, if no capturer exists, an error is returned.

func (*FakeConnector) GetResource

func (c *FakeConnector) GetResource(id manifold.ID) *Resource

GetResource returns a Resource for the ID or nil

func (*FakeConnector) RemoveResource added in v0.6.4

func (c *FakeConnector) RemoveResource(ID manifold.ID) error

RemoveResource deletes a resource stored inside the connector

func (*FakeConnector) Start

func (c *FakeConnector) Start()

Start the server or return an error if it couldn't be started

func (*FakeConnector) Stop

func (c *FakeConnector) Stop() error

Stop the server or return an error if it couldn't be stopped

func (*FakeConnector) TriggerCallback

func (c *FakeConnector) TriggerCallback(ID manifold.ID, state CallbackState, msg string, creds map[string]string) error

TriggerCallback updates the callback if it's still pending, and notifies any listeners

type FakeConnectorConfig

type FakeConnectorConfig struct {
	Product      string
	Port         uint
	ClientID     string
	ClientSecret string
	SigningKey   string
}

FakeConnectorConfig represents the values used to Configure a FakeConnector

type GrantType

type GrantType string

GrantType represents a type of access token grant

var (
	AuthorizationCodeGrantType GrantType = "authorization_code"
	ClientCredentialsGrantType GrantType = "client_credentials"
)

AuthorizationCodeGrantType represents an OAuth Authorization Code

type ProductProfile

type ProductProfile struct {
	Type   string         `json:"type"`
	Target *ProductTarget `json:"target"`
}

ProductProfile represents the data returned on GET /v1/self when the target type is a product

type ProductTarget

type ProductTarget struct {
	Name  string `json:"name"`
	Label string `json:"label"`
}

ProductTarget represents the data returned on GET /v1/vself when the target type is product

type RequestCapturer

type RequestCapturer struct {
	Route string
	// contains filtered or unexported fields
}

RequestCapturer represents functionality for capturing and storing requests for a specific route

func (*RequestCapturer) Get

func (r *RequestCapturer) Get() []interface{}

Get returns the requests captured by this Capturer

type Resource

type Resource struct {
	ID        manifold.ID       `json:"id"`
	Plan      string            `json:"plan"`
	Product   string            `json:"product"`
	Region    string            `json:"region"`
	Features  models.FeatureMap `json:"features,omitempty"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

Resource represents a resource provisioned through Grafton

type TokenRequest

type TokenRequest struct {
	ContentType  string
	Code         string
	AuthHeader   bool
	ClientID     string
	ClientSecret string
	GrantType    GrantType
	ExpiresAt    time.Time
}

TokenRequest represents all of the important values from a request by a provider to create an OAuth Token

type UserProfile

type UserProfile struct {
	Type   string      `json:"type"`
	Target *UserTarget `json:"target"`
}

UserProfile represents the data returned on GET /v1/self when the target type is a user

type UserTarget

type UserTarget struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

UserTarget represents the contents of a response on GET /v1/self when the target is a user

Jump to

Keyboard shortcuts

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