api

package
v0.0.0-...-9f7285a Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorInternalServerError = errors.New("internal server error")
View Source
var ErrorRateLimitExceeds = errors.New("ratelimit exceeds. retry it later")
View Source
var MaxRetryCount = 10
View Source
var MaxWaitTimeOnRetriableError = 60
View Source
var MinWaitTimeOnRetriableError = 5
View Source
var RetriableHttpResponseCodes = []int{
	429, 500, 501, 502, 503,
}
View Source
var RetriableWithRefreshingTokenHttpResponseCodes = []int{
	401, 403,
}

Functions

This section is empty.

Types

type GCPClient

type GCPClient interface {
	GetClusterNames(ctx context.Context, projectId string) ([]string, error)
	GetAnthosAWSClusterNames(ctx context.Context, projectId string) ([]string, error)
	GetAnthosAzureClusterNames(ctx context.Context, projectId string) ([]string, error)
	GetAnthosOnBaremetalClusterNames(ctx context.Context, projectId string) ([]string, error)
	GetAnthosOnVMWareClusterNames(ctx context.Context, projectId string) ([]string, error)
	GetComposerEnvironmentNames(ctx context.Context, projectId string, location string) ([]string, error)
	ListLogEntries(ctx context.Context, projectId string, filter string, logSink chan any) error
}

func NewGCPClient

func NewGCPClient(refresher token.TokenRefresher, headerProviders []httpclient.HTTPHeaderProvider) (GCPClient, error)

type GCPClientFactory

type GCPClientFactory struct {
	HeaderProviders []httpclient.HTTPHeaderProvider
	TokenStores     []token.TokenStore
}
var DefaultGCPClientFactory *GCPClientFactory = NewGCPClientFactory()

func NewGCPClientFactory

func NewGCPClientFactory() *GCPClientFactory

func (*GCPClientFactory) NewClient

func (f *GCPClientFactory) NewClient() (GCPClient, error)

NewClient instanciate a new GCPClient from current factory config.

func (*GCPClientFactory) RegisterHeaderProvider

func (f *GCPClientFactory) RegisterHeaderProvider(provider httpclient.HTTPHeaderProvider)

RegisterHeaderProvider adds a new HeaderProvider on factory config.

func (*GCPClientFactory) RegisterRefreshableTokenStore

func (f *GCPClientFactory) RegisterRefreshableTokenStore(store token.TokenStore)

RegisterRefreshableTokenStore adds a refreshable token store. The token will be refreshed when permission related error happens.

type GCPClientImpl

type GCPClientImpl struct {
	BaseClient httpclient.HTTPClient[*http.Response]
	// This is a parameter for limiting the result length of List log entries api call for testing purpose.
	MaxLogEntries int
}

func (*GCPClientImpl) CreateGCPHttpRequest

func (c *GCPClientImpl) CreateGCPHttpRequest(ctx context.Context, method string, url string, body io.Reader) (*http.Request, error)

func (*GCPClientImpl) Digest

func (pi *GCPClientImpl) Digest() string

Digest implements task.CachableDependency.

func (*GCPClientImpl) GetAnthosAWSClusterNames

func (c *GCPClientImpl) GetAnthosAWSClusterNames(ctx context.Context, projectId string) ([]string, error)

GetAnthosAWSClusterNames retrieves the list of Anthos on AWS cluster names.

func (*GCPClientImpl) GetAnthosAzureClusterNames

func (c *GCPClientImpl) GetAnthosAzureClusterNames(ctx context.Context, projectId string) ([]string, error)

GetAnthosAzureClusterNames retrieves the list of Anthos on Azure cluster names.

func (*GCPClientImpl) GetAnthosOnBaremetalClusterNames

func (c *GCPClientImpl) GetAnthosOnBaremetalClusterNames(ctx context.Context, projectId string) ([]string, error)

func (*GCPClientImpl) GetAnthosOnVMWareClusterNames

func (c *GCPClientImpl) GetAnthosOnVMWareClusterNames(ctx context.Context, projectId string) ([]string, error)

func (*GCPClientImpl) GetClusterNames

func (c *GCPClientImpl) GetClusterNames(ctx context.Context, projectId string) ([]string, error)

*

  • Get the list of GKE cluster names.

func (*GCPClientImpl) GetComposerEnvironmentNames

func (c *GCPClientImpl) GetComposerEnvironmentNames(ctx context.Context, projectId string, location string) ([]string, error)

Get all composer environment names from composer.googleapis.com in a region refs: https://cloud.google.com/composer/docs/reference/rest/v1/projects.locations.environments/list

func (*GCPClientImpl) GetFleetMembershipNames

func (c *GCPClientImpl) GetFleetMembershipNames(ctx context.Context, projectId string) ([]string, error)

func (*GCPClientImpl) ListLogEntries

func (c *GCPClientImpl) ListLogEntries(ctx context.Context, projectId string, filter string, logSink chan any) error

*

  • Query logs with specified filter

type PageClient

type PageClient[T any] struct {
	// contains filtered or unexported fields
}

PageClient is utility to obtain all the resource from API returning page token.

func NewPageClient

func NewPageClient[T any](client httpclient.HTTPClient[*http.Response]) *PageClient[T]

func (*PageClient[T]) GetAll

func (p *PageClient[T]) GetAll(ctx context.Context, requestGenerator RequestGenerator, nextPageTokenMapper func(response *T) string) ([]*T, error)

type RefreshableToken

type RefreshableToken interface {
	Refresh() (string, error)
}

type RequestGenerator

type RequestGenerator = func(hasToken bool, nextPageToken string) (*http.Request, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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