Documentation ¶
Index ¶
- Variables
- type Client
- func (m *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) NewRequest(ctx context.Context, method, uri string, payload any, options ...RequestOption) (*http.Request, error)
- func (c *Client) RefreshTestData() error
- func (m *Client) Request(ctx context.Context, method, uri string, payload any, result any, ...) error
- func (c *Client) URL(parts ...string) string
- type ClientOption
- func WithClientCredentials(ctx context.Context, clientID, clientSecret string, scopes ...Scope) ClientOption
- func WithCustomEnvironment(envConfig EnvironmentConfig) ClientOption
- func WithEmulator(ctx context.Context, envConfig EnvironmentConfig, scopes ...Scope) ClientOption
- func WithEnvironment(env Environment) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithStaticToken(token string) ClientOption
- func WithTokenSource(tokenSource oauth2.TokenSource) ClientOption
- type Environment
- type EnvironmentConfig
- type Error
- type ErrorCode
- type QueryOpts
- type RequestOption
- func Fields(fields ...string) RequestOption
- func Filter(filter string) RequestOption
- func Limit(n int) RequestOption
- func Page(n int) RequestOption
- func QueryOptions(q QueryOpts) RequestOption
- func Search(s string) RequestOption
- func Skip(n int) RequestOption
- func Sort(sortFields ...string) RequestOption
- type Scope
Constants ¶
This section is empty.
Variables ¶
var DefaultAgent = fmt.Sprintf("Go-BCCCoreApi/%s", Version)
var Version = "0.2.0-alpha"
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Affiliation *genericClient[models.Affiliation, models.AffiliationWrite] Consent *genericClient[models.Consent, models.ConsentWrite] Country *genericClient[models.Country, models.CountryWrite] Group *groupClient Org *genericClient[models.Org, models.OrgWrite] Person *genericClient[models.Person, models.PersonWrite] Relation *genericClient[models.Relation, models.RelationWrite] RoleAssignment *genericClient[models.RoleAssignment, models.RoleAssignmentWrite] Role *genericClient[models.Role, models.RoleWrite] // contains filtered or unexported fields }
func NewClient ¶
func NewClient(options ...ClientOption) *Client
func (*Client) Do ¶
Do triggers an HTTP request and returns an HTTP response, handling any context cancellations or timeouts.
func (*Client) NewRequest ¶
func (*Client) RefreshTestData ¶
Resets test data, only available if the SDK is run against the emulator
type ClientOption ¶
type ClientOption func(*Client)
func WithClientCredentials ¶
func WithClientCredentials(ctx context.Context, clientID, clientSecret string, scopes ...Scope) ClientOption
WithClientCredentials configures the SDK to authenticate using the client credentials authentication flow.
func WithCustomEnvironment ¶
func WithCustomEnvironment(envConfig EnvironmentConfig) ClientOption
WithCustomEnvironment sets a custom environment config for the SDK to use. Can be used to if you want to pass your requests thorugh a proxy, or to connect to an emulator
func WithEmulator ¶
func WithEmulator(ctx context.Context, envConfig EnvironmentConfig, scopes ...Scope) ClientOption
WithEmulator configures the SDK to authenticate using the client credentials authentication flow against the emulator.
func WithEnvironment ¶
func WithEnvironment(env Environment) ClientOption
WithEnvironment configures the SDK to override the used environment (by default Prod is used)
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient configures the SDK to use the provided HTTP client.
func WithStaticToken ¶
func WithStaticToken(token string) ClientOption
WithStaticToken configures the SDK to authenticate using the provided token
func WithTokenSource ¶
func WithTokenSource(tokenSource oauth2.TokenSource) ClientOption
WithTokenSource configures the SDK to authenticate using the provided token source
type Environment ¶
type Environment int
const ( EnvironmentProd Environment = iota EnvironmentSandbox EnvironmentDev )
type EnvironmentConfig ¶
type ErrorCode ¶
type ErrorCode string
const ( ErrorCodeNotFound ErrorCode = "not-found" ErrorCodeInvalidQuery ErrorCode = "invalid-query" ErrorCodeInvalidBody ErrorCode = "invalid-body" ErrorCodeInvalidKeyReference ErrorCode = "invalid-key-reference" ErrorCodeDuplicateUniqueKey ErrorCode = "duplicate-unique-key" ErrorCodeCannotParseToken ErrorCode = "cannot-parse-token" ErrorCodeInvalidToken ErrorCode = "invalid-token" ErrorCodeMissingScopes ErrorCode = "missing-scopes" ErrorCodeInternalError ErrorCode = "internal-error" ErrorCodeInvalidAppUID ErrorCode = "invalid-app-uid" ErrorCodeUnknownErrorResponse ErrorCode = "unknown-error-response" )
type RequestOption ¶
func Fields ¶
func Fields(fields ...string) RequestOption
Fields allows to specify the fields returned by the SDK See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#fields Works for Find and Get endpoints
func Filter ¶
func Filter(filter string) RequestOption
Filter the result based on the provided condition See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#filter Only works for Find endpoints
func Limit ¶
func Limit(n int) RequestOption
Limit will restrict the number of returned results to n See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#limit Only works for Find endpoints
func Page ¶
func Page(n int) RequestOption
Skip will skip the first (n - 1) * Limit rows from the results See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#page Only works for Find endpoints
func QueryOptions ¶
func QueryOptions(q QueryOpts) RequestOption
Sets additional query options See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#options Works for Find and Get endpoints
func Search ¶
func Search(s string) RequestOption
Performs a fuzzy search See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#search Only works for Find Person endpoint
func Skip ¶
func Skip(n int) RequestOption
Skip will skip the first n rows from the results See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#skip Only works for Find endpoints
func Sort ¶
func Sort(sortFields ...string) RequestOption
Sorts the result by a given field See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#sort Only works for Find endpoints
type Scope ¶
type Scope string
const ( ScopePersonsRead Scope = "persons#read" ScopePersonsNameRead Scope = "persons.name#read" ScopePersonsBirthDateRead Scope = "persons.birth_date#read" ScopePersonsDeceasedDateRead Scope = "persons.deceased_date#read" ScopePersonsNationalIdsRead Scope = "persons.national_ids#read" ScopePersonsGenderRead Scope = "persons.gender#read" ScopePersonsEmailRead Scope = "persons.email#read" ScopePersonsPhoneRead Scope = "persons.phone#read" ScopePersonsPreferencesRead Scope = "persons.preferences#read" ScopePersonsAddressRead Scope = "persons.address#read" ScopePersonsProfilePictureRead Scope = "persons.profile_picture#read" ScopePersonAffiliationsRead Scope = "persons.affiliations#read" ScopePersonRelationsRead Scope = "persons.relations#read" ScopePersonConsentsRead Scope = "persons.consents#read" ScopePersonRoleAssignmentsRead Scope = "persons.role_assignments#read" ScopePersonPersonIdRead Scope = "persons.person_id#read" ScopeOrgsRead Scope = "orgs#read" ScopeCountriesRead Scope = "countries#read" ScopeRolesRead Scope = "roles#read" ScopeGroupsRead Scope = "groups#read" ScopePersonsWrite Scope = "persons#write" ScopePersonAffiliationsWrite Scope = "persons.affiliations#write" ScopePersonRelationsWrite Scope = "persons.relations#write" ScopePersonConsentsWrite Scope = "persons.consents#write" ScopePersonRoleAssignmentsWrite Scope = "persons.role_assignments#write" ScopeOrgsWrite Scope = "orgs#write" ScopeCountriesWrite Scope = "countries#write" ScopeRolesWrite Scope = "roles#write" ScopeGroupsWrite Scope = "groups#write" )