api

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const PageTokenField = "page_token"

PageTokenField is the protobuf field that contains our page token.

Variables

View Source
var File_api_page_token_proto protoreflect.FileDescriptor

Functions

func GetResultsCount

func GetResultsCount(res PaginatedResponse) int

GetResultsCount returns the count of results from a paginated response. By convention, the first field in a paginated response contains the results slice.

func ListAllPaginated

func ListAllPaginated[ResponseType PaginatedResponse, RequestType PaginatedRequest, ResultType any](
	ctx context.Context, req RequestType, list func(context.Context, RequestType) (ResponseType, error),
	getter func(res ResponseType) []ResultType) (results []ResultType, err error)

ListAllPaginated invokes a List RPC function that supports pagination, fetches all pages using individual calls and finally combines all results of all pages into a single slice. It executes the function specified in list using the req of RequestType. Afterwards, the function getter is executed to transform the response of the list calls into the results slice.

func NewOAuthHTTPClient

func NewOAuthHTTPClient(base *http.Client, authorizer Authorizer) (client *http.Client)

NewOAuthHTTPClient returns a copy of base client that injects OAuth 2.0 bearer tokens. If authorizer is nil, base is returned as-is (or http.DefaultClient if base is nil).

Types

type Authorizer

type Authorizer interface {
	oauth2.TokenSource
}

Authorizer provides OAuth 2.0 tokens for authenticating client requests.

func NewOAuthAuthorizerFromClientCredentials

func NewOAuthAuthorizerFromClientCredentials(config *clientcredentials.Config) (authorizer Authorizer)

NewOAuthAuthorizerFromClientCredentials creates a new authorizer based on OAuth 2.0 client credentials.

func NewOAuthAuthorizerFromConfig

func NewOAuthAuthorizerFromConfig(config *oauth2.Config, token *oauth2.Token) (authorizer Authorizer)

NewOAuthAuthorizerFromConfig creates a new authorizer based on an OAuth 2.0 config.

type HasId

type HasId interface {
	GetId() string
}

HasId interface for messages that have an ID field.

type HasTargetOfEvaluationId

type HasTargetOfEvaluationId interface {
	GetTargetOfEvaluationId() string
}

HasTargetOfEvaluationId interface for messages that have a target_of_evaluation_id field.

type HasToolId

type HasToolId interface {
	GetToolId() string
}

HasToolId interface for messages that have a tool_id field.

type PageToken

type PageToken struct {

	// start is the offset in the list
	Start int64 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
	// size is the page size
	Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

PageToken is an internal message used to encode and decode page tokens for pagination. It is not intended to be used directly by clients.

func DecodePageToken

func DecodePageToken(b64token string) (t *PageToken, err error)

DecodePageToken decodes a PageToken out of a base 64 URL encoded string.

func (*PageToken) Descriptor deprecated

func (*PageToken) Descriptor() ([]byte, []int)

Deprecated: Use PageToken.ProtoReflect.Descriptor instead.

func (*PageToken) Encode

func (t *PageToken) Encode() (b64token string, err error)

Encode encodes this page token into a base64 URL encoded string.

func (*PageToken) GetSize

func (x *PageToken) GetSize() int32

func (*PageToken) GetStart

func (x *PageToken) GetStart() int64

func (*PageToken) ProtoMessage

func (*PageToken) ProtoMessage()

func (*PageToken) ProtoReflect

func (x *PageToken) ProtoReflect() protoreflect.Message

func (*PageToken) Reset

func (x *PageToken) Reset()

func (*PageToken) String

func (x *PageToken) String() string

type PaginatedRequest

type PaginatedRequest interface {
	GetPageToken() string
	GetPageSize() int32
	GetOrderBy() string // For ordering
	GetAsc() bool       // For ordering
	proto.Message
}

PaginatedRequest contains the typical parameters for a paginated request, usually a request for a List gRPC call.

type PaginatedResponse

type PaginatedResponse interface {
	GetNextPageToken() string
	proto.Message
}

PaginatedResponse contains the typical parameters for a paginated response, usually a response for a List gRPC call.

type PayloadRequest

type PayloadRequest interface {
	GetPayload() proto.Message
	proto.Message
}

PayloadRequest describes any kind of requests that carries a certain payload. This is for example a Create/Update request carrying an embedded message, which should be created or updated.

type UsesAuthorizer

type UsesAuthorizer interface {
	SetAuthorizer(auth Authorizer)
	Authorizer() Authorizer
}

UsesAuthorizer denotes a struct that can accept and use an Authorizer.

Jump to

Keyboard shortcuts

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