Documentation ¶
Index ¶
- Constants
- Variables
- func NewAdapter(client Client) framework.Adapter[Config]
- func ParseResponse(body []byte) (objects []map[string]any, nextCursor string, err *framework.Error)
- type Adapter
- func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) RequestPageFromDatasource(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) ValidateGetPageRequest(ctx context.Context, request *framework.Request[Config]) *framework.Error
- type Client
- type Config
- type Datasource
- type DatasourceResponse
- type Entity
- type Request
- type Response
Constants ¶
const ( // SCAFFOLDING #11 - pkg/adapter/datasource.go: Update the set of valid entity types this adapter supports. Users string = "users" Groups string = "groups" Teams string = "teams" )
const ( // MaxPageSize is the maximum page size allowed in a GetPage request. // // SCAFFOLDING #7 - pkg/adapter/validation.go: Update this limit to match the limit of the SoR. MaxPageSize = 100 )
Variables ¶
var ( // ValidEntityExternalIDs is a map of valid external IDs of entities that can be queried. // The map value is the Entity struct which contains the unique ID attribute. ValidEntityExternalIDs = map[string]Entity{ Users: { // contains filtered or unexported fields }, Groups: { // contains filtered or unexported fields }, Teams: { // contains filtered or unexported fields }, } )
Functions ¶
func NewAdapter ¶
NewAdapter instantiates a new Adapter.
SCAFFOLDING #21 - pkg/adapter/adapter.go: Add or remove parameters to match field updates above.
Types ¶
type Adapter ¶
type Adapter struct { // Client provides access to the datasource. Client Client }
Adapter implements the framework.Adapter interface to query pages of objects from datasources.
func (*Adapter) GetPage ¶
func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
GetPage is called by SGNL's ingestion service to query a page of objects from a datasource.
type Client ¶
type Client interface { // GetPage returns a page of JSON objects from the datasource for the // requested entity. // Returns a (possibly empty) list of JSON objects, each object being // unmarshaled into a map by Golang's JSON unmarshaler. GetPage(ctx context.Context, request *Request) (*Response, *framework.Error) }
Client is a client that allows querying the datasource which contains JSON objects.
type Config ¶
type Config struct { // Example config field. APIVersion string `json:"apiVersion,omitempty"` }
Config is the optional configuration passed in each GetPage calls to the adapter.
type Datasource ¶
Datasource directly implements a Client interface to allow querying an external datasource.
type DatasourceResponse ¶
type DatasourceResponse struct { // SCAFFOLDING #14 - pkg/adapter/datasource.go: Update `objects` with field name in the SoR response that contains the list of objects. Teams []map[string]any `json:"teams,omitempty"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` More bool `json:"more,omitempty"` }
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity contains entity specific information, such as the entity's unique ID attribute and the endpoint to query that entity.
type Request ¶
type Request struct { // BaseURL is the Base URL of the datasource to query. BaseURL string // Username is the username to use to authenticate with the datasource. Username string // Password is the password to use to authenticate with the datasource. Password string // Token is the Authorization token to use to authentication with the datasource. Token string // PageSize is the maximum number of objects to return from the entity. PageSize int64 // EntityExternalID is the external ID of the entity. // The external ID should match the API's resource name. EntityExternalID string // Cursor identifies the first object of the page to return, as returned by // the last request for the entity. // Optional. If not set, return the first page for this entity. Cursor string }
Request is a request to the datasource.
type Response ¶
type Response struct { // StatusCode is an HTTP status code. StatusCode int // RetryAfterHeader is the Retry-After response HTTP header, if set. RetryAfterHeader string // Objects is the list of // May be empty. Objects []map[string]any // NextCursor is the cursor that identifies the first object of the next // page. // May be empty. NextCursor string }
SCAFFOLDING #6 - pkg/adapter/client.go: Add/Remove/Update any fields to model the response from the SoR API. Response is a response returned by the datasource.