Documentation ¶
Overview ¶
Package invitations provides the API to manage invitations.
An invitation is a request to join a domain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRelation ¶
CheckRelation checks if the given relation is valid. It returns an error if the relation is empty or invalid.
Types ¶
type Invitation ¶
type Invitation struct { InvitedBy string `json:"invited_by"` UserID string `json:"user_id"` DomainID string `json:"domain_id"` Token string `json:"token,omitempty"` Relation string `json:"relation,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty"` ConfirmedAt time.Time `json:"confirmed_at,omitempty"` RejectedAt time.Time `json:"rejected_at,omitempty"` Resend bool `json:"resend,omitempty"` }
Invitation is an invitation to join a domain.
type InvitationPage ¶
type InvitationPage struct { Total uint64 `json:"total"` Offset uint64 `json:"offset"` Limit uint64 `json:"limit"` Invitations []Invitation `json:"invitations"` }
InvitationPage is a page of invitations.
func (InvitationPage) MarshalJSON ¶
func (page InvitationPage) MarshalJSON() ([]byte, error)
type Page ¶
type Page struct { Offset uint64 `json:"offset" db:"offset"` Limit uint64 `json:"limit" db:"limit"` InvitedBy string `json:"invited_by,omitempty" db:"invited_by,omitempty"` UserID string `json:"user_id,omitempty" db:"user_id,omitempty"` DomainID string `json:"domain_id,omitempty" db:"domain_id,omitempty"` Relation string `json:"relation,omitempty" db:"relation,omitempty"` InvitedByOrUserID string `db:"invited_by_or_user_id,omitempty"` State State `json:"state,omitempty"` }
Page is a page of invitations.
type Repository ¶
type Repository interface { // Create creates an invitation. Create(ctx context.Context, invitation Invitation) (err error) // Retrieve returns an invitation. Retrieve(ctx context.Context, userID, domainID string) (Invitation, error) // RetrieveAll returns a list of invitations based on the given page. RetrieveAll(ctx context.Context, page Page) (invitations InvitationPage, err error) // UpdateToken updates an invitation by setting the token. UpdateToken(ctx context.Context, invitation Invitation) (err error) // UpdateConfirmation updates an invitation by setting the confirmation time. UpdateConfirmation(ctx context.Context, invitation Invitation) (err error) // UpdateRejection updates an invitation by setting the rejection time. UpdateRejection(ctx context.Context, invitation Invitation) (err error) // Delete deletes an invitation. Delete(ctx context.Context, userID, domainID string) (err error) }
type Service ¶
type Service interface { // SendInvitation sends an invitation to the given user. // Only domain administrators and platform administrators can send invitations. SendInvitation(ctx context.Context, session authn.Session, invitation Invitation) (err error) // ViewInvitation returns an invitation. // People who can view invitations are: // - the invited user: they can view their own invitations // - the user who sent the invitation // - domain administrators // - platform administrators ViewInvitation(ctx context.Context, session authn.Session, userID, domainID string) (invitation Invitation, err error) // ListInvitations returns a list of invitations. // People who can list invitations are: // - platform administrators can list all invitations // - domain administrators can list invitations for their domain // By default, it will list invitations the current user has sent or received. ListInvitations(ctx context.Context, session authn.Session, page Page) (invitations InvitationPage, err error) // AcceptInvitation accepts an invitation by adding the user to the domain. AcceptInvitation(ctx context.Context, session authn.Session, domainID string) (err error) // DeleteInvitation deletes an invitation. // People who can delete invitations are: // - the invited user: they can delete their own invitations // - the user who sent the invitation // - domain administrators // - platform administrators DeleteInvitation(ctx context.Context, session authn.Session, userID, domainID string) (err error) // RejectInvitation rejects an invitation. // People who can reject invitations are: // - the invited user: they can reject their own invitations RejectInvitation(ctx context.Context, session authn.Session, domainID string) (err error) }
Service is an interface that defines methods for managing invitations.
func NewService ¶
func NewService(token magistrala.TokenServiceClient, repo Repository, sdk mgsdk.SDK) Service
type State ¶
type State uint8
State represents invitation state.
const ( All State = iota // All is used for querying purposes to list invitations irrespective of their state - both pending and accepted. Pending // Pending is the state of an invitation that has not been accepted yet. Accepted // Accepted is the state of an invitation that has been accepted. Rejected // Rejected is the state of an invitation that has been rejected. )
func (State) MarshalJSON ¶
func (*State) UnmarshalJSON ¶
Custom Unmarshaler for Client/Groups.
Directories ¶
Path | Synopsis |
---|---|
Package middleware contains the middleware for the invitations service.
|
Package middleware contains the middleware for the invitations service. |
Package mocks provides a mock implementation of the invitations repository.
|
Package mocks provides a mock implementation of the invitations repository. |
Package postgres provides a postgres implementation of the invitations repository.
|
Package postgres provides a postgres implementation of the invitations repository. |
Click to show internal directories.
Click to hide internal directories.