rest

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Domain string

This global setting identifies which back end to use, and defaults to api.observability.postman.com.

The domain is chosen based on the selected Postman environment (which may be the default or set in an environment variable.)

If the --domain flag is used, it unconditionally overrides this choice.

View Source
var ExpectedServerName string

Accept a server name other than the expected one in the TLS handshake

View Source
var (
	// Shared client to maximize connection re-use.
	// TODO: make this private to the package once kgx package is removed.
	HTTPClient *retryablehttp.Client
)
View Source
var PermitInvalidCertificate bool

Connect even if the certificate does not validate.

View Source
var ProxyAddress string

Use a proxy, "" is none. (This is because the flags package doesn't support Optional) May be a URL, a domain name, or an IP address. HTTP is assumed as the protocol if none is provided.

Functions

func DefaultDomain

func DefaultDomain() string

Return the default domain, given the settings in use

func GetUserAgent

func GetUserAgent() string

func NewFrontClient

func NewFrontClient(host string, cli akid.ClientID) *frontClientImpl

func NewLearnClient

func NewLearnClient(host string, cli akid.ClientID, svc akid.ServiceID) *learnClientImpl

func SetAPIErrorHandler

func SetAPIErrorHandler(f APIErrorHandler)

Types

type APIErrorHandler

type APIErrorHandler = func(method string, path string, e error)

Error handling (to call into the telemetry library without creating a circular dependency.)

type BaseClient

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

func NewBaseClient

func NewBaseClient(rawHost string, cli akid.ClientID) BaseClient

func (BaseClient) Get

func (c BaseClient) Get(ctx context.Context, path string, resp interface{}) error

Sends GET request and parses the response as JSON.

func (BaseClient) GetWithQuery

func (c BaseClient) GetWithQuery(ctx context.Context, path string, query url.Values, resp interface{}) (e error)

func (BaseClient) Post

func (c BaseClient) Post(ctx context.Context, path string, body interface{}, resp interface{}) (e error)

Sends POST request after marshaling body into JSON and parses the response as JSON.

type CreateServiceResponse

type CreateServiceResponse struct {
	RequestID  akid.RequestID `json:"request_id"`
	ResourceID akid.ServiceID `json:"resource_id"`
}

type CreateSpecOptions

type CreateSpecOptions struct {
	Tags           map[tags.Key]string
	Versions       []string
	PathExclusions []*regexp.Regexp
	GitHubPR       *github.PRInfo
	GitLabMR       *gitlab.MRInfo
	TimeRange      *time_span.TimeSpan
}

type ErrorResponse

type ErrorResponse struct {
	RequestID  akid.RequestID `json:"request_id"`
	Message    string         `json:"message"`
	ResourceID string         `json:"resource_id"`
}

type FrontClient

type FrontClient interface {
	GetServices(context.Context) ([]Service, error)
	GetService(context.Context, akid.ServiceID) (InsightsService, error)
	GetUser(context.Context) (PostmanUser, error)
	CreateService(context.Context, string, string) (CreateServiceResponse, error)
	DaemonHeartbeat(ctx context.Context, daemonName string) error

	// Long-polls for changes to the set of active traces for a service.
	// Callers specify what they think the current set of active traces is. When
	// the cloud has a different set, this method returns options for capturing
	// new traces and a set of deactivated traces. An error is returned if the
	// connection is dropped (e.g., due to timing out).
	LongPollActiveTracesForService(context context.Context, daemonName string, serviceID akid.ServiceID, currentTraces []akid.LearnSessionID) (daemon.ActiveTraceDiff, error)
}

type GetSpecOptions

type GetSpecOptions struct {
	EnableRelatedTypes bool
}

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       []byte
}

Error type for non-2xx HTTP errors.

func (HTTPError) Error

func (he HTTPError) Error() string

type InsightsService

type InsightsService struct {
	ID   akid.ServiceID `json:"service_id"`
	Name string         `json:"service_name"`
}

type LearnClient

type LearnClient interface {
	ListLearnSessions(
		ctx context.Context,
		serviceID akid.ServiceID,
		tags map[tags.Key]string,
		limit int,
		offset int,
	) ([]*kgxapi.ListedLearnSession, error)
	ListLearnSessionsWithStats(context.Context, akid.ServiceID, int) ([]*kgxapi.ListedLearnSession, error)
	GetLearnSession(context.Context, akid.ServiceID, akid.LearnSessionID) (*kgxapi.LearnSession, error)
	CreateLearnSession(context.Context, *kgxapi.APISpecReference, string, map[tags.Key]string) (akid.LearnSessionID, error)

	// Uploads a batch of reports to Akita Cloud. This method is responsible for
	// filling in the ClientID in the given ReportsUploadRequest.
	AsyncReportsUpload(context.Context, akid.LearnSessionID, *kgxapi.UploadReportsRequest) error

	// Creates a spec from a set of learn sessions.
	CreateSpec(context.Context, string, []akid.LearnSessionID, CreateSpecOptions) (akid.APISpecID, error)
	GetSpec(context.Context, akid.APISpecID, GetSpecOptions) (kgxapi.GetSpecResponse, error)
	GetSpecVersion(context.Context, string) (kgxapi.APISpecVersion, error)
	UploadSpec(context.Context, kgxapi.UploadSpecRequest) (*kgxapi.UploadSpecResponse, error)

	// Resolve names.
	GetAPISpecIDByName(context.Context, string) (akid.APISpecID, error)
	GetLearnSessionIDByName(context.Context, string) (akid.LearnSessionID, error)

	// Spec diff
	GetSpecDiffTrie(context.Context, akid.APISpecID, akid.APISpecID) (*path_trie.PathTrie, error)

	// Telemetry
	PostClientPacketCaptureStats(context.Context, akid.ServiceID, kgxapi.PostClientPacketCaptureStatsRequest) error
	PostInitialClientTelemetry(context.Context, akid.ServiceID, kgxapi.PostInitialClientTelemetryRequest) error
}

type PostmanMetaData

type PostmanMetaData struct {
	CollectionID string `json:"collection_id"`
	Environment  string `json:"environment,omitempty"`
}

type PostmanUser

type PostmanUser struct {
	ID     int    `json:"id"`
	Email  string `json:"email"`
	TeamID int    `json:"team_id"`
}

type Service

type Service struct {
	ID              akid.ServiceID  `json:"id"`
	Name            string          `json:"name"`
	PostmanMetaData PostmanMetaData `json:"postman_meta_data"`
}

TODO: shouldn't this be in akita-cli/api_schema?

type User

type User = api_schema.UserResponse

Jump to

Keyboard shortcuts

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