coreapi

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AffiliationsPath    = "/affiliations"
	ConsentsPath        = "/consents"
	CountriesPath       = "/countries"
	GroupsPath          = "/groups"
	OrgsPath            = "/v2/orgs"
	PersonsPath         = "/v2/persons"
	RelationsPath       = "/relations"
	RoleAssignmentsPath = "/roleAssignments"
	RolesPath           = "/roles"
)
View Source
const MemberPath = "/members"
View Source
const UrlDev = "https://dev-api.bcc.no"
View Source
const UrlProd = "https://api.bcc.no"
View Source
const UrlSandbox = "https://sandbox-api.bcc.no"

Variables

View Source
var CredEnvDev = ClientCredentialsEnv{
	TokenUrl: "https://bcc-sso-dev.eu.auth0.com/oauth/token",
	Audience: "dev-api.bcc.no",
}
View Source
var CredEnvProd = ClientCredentialsEnv{
	TokenUrl: "https://bcc-sso.eu.auth0.com/oauth/token",
	Audience: "api.bcc.no",
}
View Source
var CredEnvSandbox = ClientCredentialsEnv{
	TokenUrl: "https://bcc-sso-sandbox.eu.auth0.com/oauth/token",
	Audience: "sandbox-api.bcc.no",
}
View Source
var DefaultAgent = fmt.Sprintf("Go-Coreapi/%s", Version)
View Source
var GroupPath = "/groups"
View Source
var Version = "0.1.0-alpha.2"

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 New

func New(url string, options ...ClientOption) *Client

func (*Client) Do

func (m *Client) Do(req *http.Request) (*http.Response, error)

Do triggers an HTTP request and returns an HTTP response, handling any context cancellations or timeouts.

func (*Client) NewRequest

func (c *Client) NewRequest(
	ctx context.Context,
	method,
	uri string,
	payload any,
	options ...RequestOption,
) (*http.Request, error)

func (*Client) RefreshTestData

func (c *Client) RefreshTestData() error

Resets test data, only available if the SDK is run against the emulator

func (*Client) Request

func (m *Client) Request(ctx context.Context, method, uri string, payload any, result any, options ...RequestOption) error

Request combines NewRequest and Do, while also handling decoding of response payload.

Can be used to provide a custom payload type for a request

func (*Client) URL

func (c *Client) URL(parts ...string) string

Joins provided url parts with the base url to build the endpoint for calling

type ClientCredentialsEnv

type ClientCredentialsEnv struct {
	TokenUrl string
	Audience string
}

type ClientOption

type ClientOption func(*Client)

func WithClient

func WithClient(client *http.Client) ClientOption

WithClient configures the SDK to use the provided client.

func WithClientCredentials

func WithClientCredentials(ctx context.Context, credEnv ClientCredentialsEnv, clientID, clientSecret string, scopes ...Scope) ClientOption

WithClientCredentials configures the SDK to authenticate using the client credentials authentication flow.

func WithEmulator

func WithEmulator(ctx context.Context, credEnv ClientCredentialsEnv, scopes ...Scope) ClientOption

WithClientCredentials configures the SDK to authenticate using the client credentials authentication flow against the emulator.

func WithStaticToken

func WithStaticToken(token string) ClientOption

WithClientCredentials configures the SDK to authenticate using the provided token

func WithTokenSource

func WithTokenSource(tokenSource oauth2.TokenSource) ClientOption

WithClientCredentials configures the SDK to authenticate using the provided token source

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

func (*Error) Error

func (m *Error) Error() string

Error formats the error into a string representation.

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"
	ErrorCodeUnauthorized         ErrorCode = "unauthorized"
	ErrorCodeInvalidAppUID        ErrorCode = "invalid-app-uid"
	ErrorCodeUnknownErrorResponse ErrorCode = "unknown-error-response"
)

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

type GroupClient

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

func (*GroupClient) AddMember

func (m *GroupClient) AddMember(ctx context.Context, groupUID strfmt.UUID, member models.GroupMemberWrite, opts ...RequestOption) (models.Wrapped[models.GroupMember], error)

func (*GroupClient) Create

func (c *GroupClient) Create(ctx context.Context, aff W) (models.Wrapped[R], error)

func (*GroupClient) Find

func (c *GroupClient) Find(ctx context.Context, opts ...RequestOption) (models.WrappedWithMeta[[]R], error)

func (*GroupClient) FindMembers

func (m *GroupClient) FindMembers(ctx context.Context, groupUID strfmt.UUID, opts ...RequestOption) (models.WrappedWithMeta[[]models.GroupMember], error)

func (*GroupClient) Get

func (c *GroupClient) Get(ctx context.Context, uid strfmt.UUID, opts ...RequestOption) (models.Wrapped[R], error)

func (*GroupClient) GetMember

func (m *GroupClient) GetMember(ctx context.Context, groupUID strfmt.UUID, memberUID strfmt.UUID, opts ...RequestOption) (models.Wrapped[models.GroupMember], error)

func (*GroupClient) Remove

func (c *GroupClient) Remove(ctx context.Context, uid strfmt.UUID) (models.Wrapped[R], error)

func (*GroupClient) RemoveMember

func (m *GroupClient) RemoveMember(ctx context.Context, groupUID strfmt.UUID, memberUID strfmt.UUID, opts ...RequestOption) (models.Wrapped[models.GroupMember], error)

func (*GroupClient) Update

func (c *GroupClient) Update(ctx context.Context, uid strfmt.UUID, aff W) (models.Wrapped[R], error)

type QueryOpts

type QueryOpts struct {
	IncludePersonsWithoutChurchAffiliation bool     `json:"includePersonsWithoutChurchAffiliation"`
	IncludeInactive                        []string `json:"includeInactive"`
	OrgUIDs                                []uuid.UUID
}

type RequestOption

type RequestOption func(*http.Request)

func Fields

func Fields(fields ...string) RequestOption

func Filter

func Filter(filter string) RequestOption

func Limit

func Limit(n int) RequestOption

func Page

func Page(n int) RequestOption

func QueryOptions

func QueryOptions(q QueryOpts) RequestOption
func Search(s string) RequestOption

func Skip

func Skip(n int) RequestOption

func Sort

func Sort(sortFields ...string) RequestOption

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"
)

Jump to

Keyboard shortcuts

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