cf

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRetryTimeout sets the amount of time before a retry times out
	DefaultRetryTimeout = time.Minute
	// DefaultRetryPause sets the amount of time to wait before retrying
	DefaultRetryPause = 3 * time.Second
)

Variables

View Source
var ErrRetry = errors.New("retry")

Functions

func NewClient

func NewClient(cfg *Config, options ...func(*client)) (*client, error)

func WithHTTPClient

func WithHTTPClient(c *http.Client) func(*client)

func WithRetryPause

func WithRetryPause(t time.Duration) func(*client)

func WithRetryTimeout

func WithRetryTimeout(t time.Duration) func(*client)

Types

type APIClient

type APIClient interface {
	BindRoute(routeGUID, appGUID string) error

	CreateApp(request cfclient.AppCreateRequest) (cfclient.App, error)
	CreateOrg(req cfclient.OrgRequest) (cfclient.Org, error)
	CreateSpace(req cfclient.SpaceRequest) (cfclient.Space, error)
	CreateRoute(request cfclient.RouteRequest) (cfclient.Route, error)
	CreateServiceBinding(appGUID, serviceInstanceGUID string) (*cfclient.ServiceBinding, error)

	DeleteApp(guid string) error
	DeleteOrg(guid string, recursive, async bool) error

	DoRequest(req *cfclient.Request) (*http.Response, error)
	Do(req *http.Request) (*http.Response, error)

	AppByName(appName, spaceGuid, orgGuid string) (cfclient.App, error)
	GetAppByGuidNoInlineCall(guid string) (cfclient.App, error)
	GetDomainByName(name string) (cfclient.Domain, error)
	GetOrgByGuid(guid string) (cfclient.Org, error)
	GetOrgByName(name string) (cfclient.Org, error)
	GetOrgQuotaByName(name string) (cfclient.OrgQuota, error)
	GetSharedDomainByName(name string) (cfclient.SharedDomain, error)
	GetSpaceByGuid(guid string) (cfclient.Space, error)
	GetSpaceByName(name string, orgGUID string) (cfclient.Space, error)
	GetStackByGuid(guid string) (cfclient.Stack, error)

	ListOrgs() ([]cfclient.Org, error)
	ListSpaces() ([]cfclient.Space, error)

	ListAppsByQuery(params url.Values) ([]cfclient.App, error)
	ListOrgsByQuery(params url.Values) ([]cfclient.Org, error)
	ListRoutesByQuery(params url.Values) ([]cfclient.Route, error)
	ListServiceInstancesByQuery(params url.Values) ([]cfclient.ServiceInstance, error)
	ListSpacesByQuery(query url.Values) ([]cfclient.Space, error)
	ListStacksByQuery(params url.Values) ([]cfclient.Stack, error)
	ListUserProvidedServiceInstancesByQuery(params url.Values) ([]cfclient.UserProvidedServiceInstance, error)

	NewRequest(method, path string) *cfclient.Request
	NewRequestWithBody(method, path string, body io.Reader) *cfclient.Request

	UpdateApp(guid string, aur cfclient.AppUpdateResource) (cfclient.UpdateResponse, error)
	UpdateV3App(guid string, req cfclient.UpdateV3AppRequest) (*cfclient.V3App, error)

	UploadAppBits(io.Reader, string) error
	UploadDropletBits(io.Reader, string) (string, error)
}

APIClient defines requests that can be made to the APIClient API

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) Load

func (c *Cache) Load(key string) (value interface{}, ok bool)

Load retrieves the item from the cache if exists. Returns the val and true if it exists otherwise false.

func (*Cache) LoadOrStore

func (c *Cache) LoadOrStore(key string, val interface{}) (actual interface{}, loaded bool)

LoadOrStore atomically returns the already stored object if found and true, otherwise it stores the given object, returns val and false

func (*Cache) Store

func (c *Cache) Store(key string, val interface{})

Store atomically stores the given object regardless if it exists

type CachingClient

type CachingClient struct {
	*cfclient.Client
	// contains filtered or unexported fields
}

func NewCachingClient

func NewCachingClient(client *cfclient.Client) *CachingClient

func (*CachingClient) GetOrgByGuid

func (c *CachingClient) GetOrgByGuid(orgGUID string) (cfclient.Org, error)

func (*CachingClient) GetOrgByName

func (c *CachingClient) GetOrgByName(name string) (cfclient.Org, error)

func (*CachingClient) GetServiceByGuid

func (c *CachingClient) GetServiceByGuid(serviceGUID string) (cfclient.Service, error)

func (*CachingClient) GetServicePlanByGUID

func (c *CachingClient) GetServicePlanByGUID(servicePlanGUID string) (*cfclient.ServicePlan, error)

func (*CachingClient) GetSpaceByGuid

func (c *CachingClient) GetSpaceByGuid(spaceGUID string) (cfclient.Space, error)

func (*CachingClient) GetSpaceByName

func (c *CachingClient) GetSpaceByName(name string, orgGUID string) (cfclient.Space, error)

func (*CachingClient) ListOrgs

func (c *CachingClient) ListOrgs() ([]cfclient.Org, error)

func (*CachingClient) ListSpaces

func (c *CachingClient) ListSpaces() ([]cfclient.Space, error)

type Client

type Client interface {
	APIClient
	DoWithRetry(f func() error) error
	Get(url string) ([]byte, error)
	GetClientConfig() *cfclient.Config
	HTTPClient() *http.Client
	Target() string
}

type Config

type Config struct {
	AccessToken           string
	RefreshToken          string
	Target                string
	AuthorizationEndpoint string
	OrganizationFields    struct {
		Name string
	}
	SpaceFields struct {
		Name string
	}
	SSLDisabled  bool
	Username     string
	Password     string
	ClientID     string
	ClientSecret string
	// contains filtered or unexported fields
}

func (*Config) HTTPClient

func (c *Config) HTTPClient() *http.Client

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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