Documentation
¶
Index ¶
- Constants
- Variables
- func GetResultsCount(res PaginatedResponse) int
- func ListAllPaginated[ResponseType PaginatedResponse, RequestType PaginatedRequest, ResultType any](ctx context.Context, req RequestType, ...) (results []ResultType, err error)
- func NewOAuthHTTPClient(base *http.Client, authorizer Authorizer) (client *http.Client)
- type Authorizer
- type HasId
- type HasTargetOfEvaluationId
- type HasToolId
- type PageToken
- func (*PageToken) Descriptor() ([]byte, []int)deprecated
- func (t *PageToken) Encode() (b64token string, err error)
- func (x *PageToken) GetSize() int32
- func (x *PageToken) GetStart() int64
- func (*PageToken) ProtoMessage()
- func (x *PageToken) ProtoReflect() protoreflect.Message
- func (x *PageToken) Reset()
- func (x *PageToken) String() string
- type PaginatedRequest
- type PaginatedResponse
- type PayloadRequest
- type UsesAuthorizer
Constants ¶
const PageTokenField = "page_token"
PageTokenField is the protobuf field that contains our page token.
Variables ¶
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 ¶
DecodePageToken decodes a PageToken out of a base 64 URL encoded string.
func (*PageToken) Descriptor
deprecated
func (*PageToken) ProtoMessage ¶
func (*PageToken) ProtoMessage()
func (*PageToken) ProtoReflect ¶
func (x *PageToken) ProtoReflect() protoreflect.Message
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 ¶
PaginatedResponse contains the typical parameters for a paginated response, usually a response for a List gRPC call.
type PayloadRequest ¶
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.