common

package
v0.0.0-...-0b62ed1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP            DataType = "APP"
	APP_INST                = "APP_INST"
	APP_STATS               = "APP_STATS"
	SPACE                   = "SPACE"
	ORG                     = "ORG"
	DOMAIN_PRIVATE          = "DOMAIN_PRIVATE"
	DOMAIN_SHARED           = "DOMAIN_SHARED"
	ISO_SEG                 = "ISO_SEG"
	ORG_QUOTA               = "ORG_QUOTA"
	SPACE_QUOTA             = "SPACE_QUOTA"
	ROUTE                   = "ROUTE"
	STACK                   = "STACK"
	EVENTS_CRASH            = "EVENTS_CRASH"
)
View Source
const ALL = "ALL"
View Source
const AUTH_ERROR = "Authentication has expired"
View Source
const DefaultMinimumReloadDuration = time.Millisecond * 10000
View Source
const DelayedRemovalFromCacheDuration = 15 * time.Second
View Source
const Infinity time.Duration = 1<<63 - 1
View Source
const MaxLoadAttempts = 5
View Source
const WaitToReloadOnErrorDuration = time.Second * 30

Variables

View Source
var DataTypeDisplay = map[DataType]string{
	APP:            "Application",
	APP_INST:       "Application Instance",
	APP_STATS:      "Application Stat",
	SPACE:          "Space",
	ORG:            "Organization",
	DOMAIN_PRIVATE: "Private Domain",
	DOMAIN_SHARED:  "Shared Domain",
	ISO_SEG:        "Isolation Segment",
	ORG_QUOTA:      "Organization Quota",
	SPACE_QUOTA:    "Space Quota",
	ROUTE:          "Route",
	STACK:          "Stack",
	EVENTS_CRASH:   "Event Crash",
}

Functions

func CallAPI

func CallAPI(cliConnection plugin.CliConnection, url string) (string, error)

func CallPagableAPI

func CallPagableAPI(cliConnection plugin.CliConnection, url string, handleResponse handleResponseFunc) error

func GetIntValueByFieldName

func GetIntValueByFieldName(n interface{}, field_name string) (int64, bool)

func GetObjectValueByFieldName

func GetObjectValueByFieldName(n interface{}, field_name string) (interface{}, bool)

func GetStringValueByFieldName

func GetStringValueByFieldName(n interface{}, field_name string) (string, bool)

func RegisterMetadataHandler

func RegisterMetadataHandler(dataType DataType, metadataHandler MetadataHandler)

Types

type APIVersion

type APIVersion int
const (
	API_V2 APIVersion = 2
	API_V3 APIVersion = 3
)

type CommonMetadataManager

type CommonMetadataManager struct {
	MetadataMapMutex sync.Mutex
	MetadataMap      map[string]IMetadata
	// contains filtered or unexported fields
}

func NewCommonMetadataManager

func NewCommonMetadataManager(
	mdGlobalManager MdGlobalManagerInterface,
	dataType DataType,
	url string,
	mm MetadataManager,
	minimumReloadDuration time.Duration) *CommonMetadataManager

func (*CommonMetadataManager) AddItem

func (commonMgr *CommonMetadataManager) AddItem(metadataItem IMetadata)

func (*CommonMetadataManager) CacheSize

func (commonMgr *CommonMetadataManager) CacheSize() int

func (*CommonMetadataManager) Clear

func (commonMgr *CommonMetadataManager) Clear()

func (*CommonMetadataManager) DelayedRemovalFromCache

func (commonMgr *CommonMetadataManager) DelayedRemovalFromCache(guid string, itemName string)

Called via a seperate thread - after a delay, remove the requested guid from cache

func (*CommonMetadataManager) DeleteItem

func (commonMgr *CommonMetadataManager) DeleteItem(guid string)

func (*CommonMetadataManager) FindItemInternal

func (commonMgr *CommonMetadataManager) FindItemInternal(guid string, requestLoadIfNotFound bool, createEmptyObjectIfNotFound bool) (IMetadata, bool)

func (*CommonMetadataManager) GetMdGlobalManager

func (commonMgr *CommonMetadataManager) GetMdGlobalManager() MdGlobalManagerInterface

func (*CommonMetadataManager) GetUrl

func (commonMgr *CommonMetadataManager) GetUrl() string

func (*CommonMetadataManager) IsDeletedFromCache

func (commonMgr *CommonMetadataManager) IsDeletedFromCache(guid string) bool

func (*CommonMetadataManager) IsPendingDeleteFromCache

func (commonMgr *CommonMetadataManager) IsPendingDeleteFromCache(guid string) bool

func (*CommonMetadataManager) LastLoadTime

func (commonMgr *CommonMetadataManager) LastLoadTime(dataKey string) *time.Time

Last time data was loaded or nil if never

func (*CommonMetadataManager) LoadItem

func (commonMgr *CommonMetadataManager) LoadItem(guid string) error

func (*CommonMetadataManager) MetadataLoadMethod

func (commonMgr *CommonMetadataManager) MetadataLoadMethod(guid string) error

func (*CommonMetadataManager) MinimumReloadDuration

func (commonMgr *CommonMetadataManager) MinimumReloadDuration() time.Duration

func (*CommonMetadataManager) PostProcessLoad

func (commonMgr *CommonMetadataManager) PostProcessLoad(metadataArray []IMetadata, err error)

type CommonV2ResponseManager

type CommonV2ResponseManager struct {
	*CommonMetadataManager
	// contains filtered or unexported fields
}

func NewCommonV2ResponseManager

func NewCommonV2ResponseManager(mdGlobalManager MdGlobalManagerInterface,
	dataType DataType,
	url string,
	mm V2MetadataManager,
	autoFullLoadIfNotFound bool) *CommonV2ResponseManager

func (*CommonV2ResponseManager) Count

func (commonV2ResponseMgr *CommonV2ResponseManager) Count(response IResponse) int

func (*CommonV2ResponseManager) FindItemInternal

func (commonV2ResponseMgr *CommonV2ResponseManager) FindItemInternal(guid string, requestLoadIfNotFound bool, createEmptyObjectIfNotFound bool) IMetadata

func (*CommonV2ResponseManager) GetMetadata

func (commonV2ResponseMgr *CommonV2ResponseManager) GetMetadata() ([]IMetadata, error)

func (*CommonV2ResponseManager) GetMetadataFromUrl

func (commonV2ResponseMgr *CommonV2ResponseManager) GetMetadataFromUrl(url string) ([]IMetadata, error)

func (*CommonV2ResponseManager) GetNextUrl

func (commonV2ResponseMgr *CommonV2ResponseManager) GetNextUrl(response IResponse) string

func (*CommonV2ResponseManager) LoadAllItems

func (commonV2ResponseMgr *CommonV2ResponseManager) LoadAllItems() error

func (*CommonV2ResponseManager) LoadAllItemsAysnc

func (commonV2ResponseMgr *CommonV2ResponseManager) LoadAllItemsAysnc()

func (*CommonV2ResponseManager) LoadAllItemsInternal

func (commonV2ResponseMgr *CommonV2ResponseManager) LoadAllItemsInternal() ([]IMetadata, error)

func (*CommonV2ResponseManager) LoadItemInternal

func (commonV2ResponseMgr *CommonV2ResponseManager) LoadItemInternal(guid string) (IMetadata, error)

func (*CommonV2ResponseManager) MetadataLoadMethod

func (commonV2ResponseMgr *CommonV2ResponseManager) MetadataLoadMethod(guid string) error

type DataType

type DataType string

type EntityCommon

type EntityCommon struct {
	Guid string `json:"guid"`
	IEntity
}

func (*EntityCommon) GetGuid

func (entity *EntityCommon) GetGuid() string

func (*EntityCommon) SetGuid

func (entity *EntityCommon) SetGuid(guid string)

type ICommonResponseManager

type ICommonResponseManager interface {
	GetMetadataFromUrl(url string) ([]IMetadata, error)
}

type IEntity

type IEntity interface {
	GetGuid() string
	SetGuid(string)
	GetName() string
}

type IMetadata

type IMetadata interface {
	IEntity
	SetCacheTime(*time.Time)
	GetCacheTime() *time.Time
}

type IResource

type IResource interface {
}

type IResourceMetadata

type IResourceMetadata interface {
}

type IResponse

type IResponse interface {
}

type IResponseV3

type IResponseV3 interface {
	GetPagination() Pagination
}
type Link struct {
	Href string `json:"href"`
}

type LoadHandler

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

func NewLoadHandler

func NewLoadHandler(conn plugin.CliConnection) *LoadHandler

func (*LoadHandler) RequestLoad

func (lh *LoadHandler) RequestLoad(loadRequest *LoadRequest)

func (*LoadHandler) RequestLoadOfAll

func (lh *LoadHandler) RequestLoadOfAll(dataType DataType, delayBeforeLoad time.Duration)

func (*LoadHandler) RequestLoadOfItem

func (lh *LoadHandler) RequestLoadOfItem(dataType DataType, guid string, delayBeforeLoad time.Duration)

type LoadRequest

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

type MdGlobalManagerInterface

type MdGlobalManagerInterface interface {
	GetCliConnection() plugin.CliConnection
	GetAppMetadataFromUrl(url string) ([]IMetadata, error)
	SetStatus(status string)
}

type Meta

type Meta struct {
	Guid      string `json:"guid"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type MetaV3

type MetaV3 struct {
	Guid string `json:"guid"`
}

type Metadata

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

func NewMetadata

func NewMetadata() *Metadata

func (*Metadata) GetCacheTime

func (md *Metadata) GetCacheTime() *time.Time

func (*Metadata) SetCacheTime

func (md *Metadata) SetCacheTime(time *time.Time)

type MetadataHandler

type MetadataHandler interface {
	MetadataLoadMethod(guid string) error
	MinimumReloadDuration() time.Duration
	LastLoadTime(dataKey string) *time.Time
}

type MetadataManager

type MetadataManager interface {
	NewItemById(guid string) IMetadata
	LoadItemInternal(guid string) (IMetadata, error)
}

type Pagination

type Pagination struct {
	Count int  `json:"total_results"`
	Pages int  `json:"total_pages"`
	Next  Link `json:"next"`
}

type ResponseError

type ResponseError struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
	ErrorCode   string `json:"error_code"`
}

type V2MetadataManager

type V2MetadataManager interface {
	MetadataManager
	LoadAllItemsInternal() ([]IMetadata, error)

	CreateResponseObject() IResponse
	CreateResourceObject() IResource
	CreateMetadataEntityObject(guid string) IMetadata
	ProcessResponse(IResponse, []IMetadata) []IMetadata
	ProcessResource(resource IResource) IMetadata
	GetNextUrl(response IResponse) string
	Count(response IResponse) int
	PostProcessLoad([]IMetadata, error)
}

Jump to

Keyboard shortcuts

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