resource

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 79

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppTrait

func GetAppTrait(resource *v2.Resource) (*v2.AppTrait, error)

GetAppTrait attempts to return the AppTrait instance on a resource.

func GetGroupTrait

func GetGroupTrait(resource *v2.Resource) (*v2.GroupTrait, error)

GetGroupTrait attempts to return the GroupTrait instance on a resource.

func GetProfileInt64Value

func GetProfileInt64Value(profile *structpb.Struct, k string) (int64, bool)

GetProfileInt64Value returns an int64 and true if the value is found.

func GetProfileStringValue

func GetProfileStringValue(profile *structpb.Struct, k string) (string, bool)

GetProfileStringValue returns a string and true if the value is found.

func GetRoleTrait

func GetRoleTrait(resource *v2.Resource) (*v2.RoleTrait, error)

GetRoleTrait attempts to return the RoleTrait instance on a resource.

func GetUserTrait

func GetUserTrait(resource *v2.Resource) (*v2.UserTrait, error)

GetUserTrait attempts to return the UserTrait instance on a resource.

func NewAppResource

func NewAppResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	appTraitOpts []AppTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewAppResource returns a new resource instance with a configured app trait. The trait is configured with the provided helpURL and profile.

func NewAppTrait

func NewAppTrait(opts ...AppTraitOption) (*v2.AppTrait, error)

NewAppTrait creates a new `AppTrait` with the given help URL, and profile.

func NewGroupResource

func NewGroupResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	groupTraitOpts []GroupTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewGroupResource returns a new resource instance with a configured group trait. The trait is configured with the provided profile.

func NewGroupTrait

func NewGroupTrait(opts ...GroupTraitOption) (*v2.GroupTrait, error)

NewGroupTrait creates a new `GroupTrait` with the provided profile.

func NewResource

func NewResource(name string, resourceType *v2.ResourceType, objectID interface{}, resourceOptions ...ResourceOption) (*v2.Resource, error)

NewResource returns a new resource instance with no traits.

func NewResourceID

func NewResourceID(resourceType *v2.ResourceType, objectID interface{}) (*v2.ResourceId, error)

NewResourceID returns a new resource ID given a resource type parent ID, and arbitrary object ID.

func NewResourceType

func NewResourceType(name string, requiredTraits []v2.ResourceType_Trait, msgs ...proto.Message) *v2.ResourceType

NewResourceType returns a new *v2.ResourceType where the id is the name lowercased with spaces replaced by hyphens.

func NewRoleResource

func NewRoleResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	roleTraitOpts []RoleTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewRoleResource returns a new resource instance with a configured role trait. The trait is configured with the provided profile.

func NewRoleTrait

func NewRoleTrait(opts ...RoleTraitOption) (*v2.RoleTrait, error)

NewRoleTrait creates a new `RoleTrait` with the provided profile.

func NewUserResource

func NewUserResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	userTraitOpts []UserTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewUserResource returns a new resource instance with a configured user trait. The trait is configured with the provided email address and profile and status set to enabled.

func NewUserTrait

func NewUserTrait(opts ...UserTraitOption) (*v2.UserTrait, error)

NewUserTrait creates a new `UserTrait`.

Types

type AppTraitOption

type AppTraitOption func(gt *v2.AppTrait) error

func WithAppHelpURL

func WithAppHelpURL(helpURL string) AppTraitOption

func WithAppIcon

func WithAppIcon(assetRef *v2.AssetRef) AppTraitOption
func WithAppLogo(assetRef *v2.AssetRef) AppTraitOption

func WithAppProfile

func WithAppProfile(profile map[string]interface{}) AppTraitOption

type GroupTraitOption

type GroupTraitOption func(gt *v2.GroupTrait) error

func WithGroupIcon

func WithGroupIcon(assetRef *v2.AssetRef) GroupTraitOption

func WithGroupProfile

func WithGroupProfile(profile map[string]interface{}) GroupTraitOption

type ResourceOption

type ResourceOption func(*v2.Resource) error

func WithAnnotation

func WithAnnotation(msgs ...proto.Message) ResourceOption

func WithAppTrait

func WithAppTrait(opts ...AppTraitOption) ResourceOption

func WithGroupTrait

func WithGroupTrait(opts ...GroupTraitOption) ResourceOption

func WithParentResourceID

func WithParentResourceID(parentResourceID *v2.ResourceId) ResourceOption

func WithRoleTrait

func WithRoleTrait(opts ...RoleTraitOption) ResourceOption

func WithUserTrait

func WithUserTrait(opts ...UserTraitOption) ResourceOption

type RoleTraitOption

type RoleTraitOption func(gt *v2.RoleTrait) error

func WithRoleProfile

func WithRoleProfile(profile map[string]interface{}) RoleTraitOption

type UserTraitOption

type UserTraitOption func(ut *v2.UserTrait) error

func WithAccountType

func WithAccountType(accountType v2.UserTrait_AccountType) UserTraitOption

func WithEmail

func WithEmail(email string, primary bool) UserTraitOption

func WithStatus

func WithStatus(status v2.UserTrait_Status_Status) UserTraitOption

func WithUserIcon

func WithUserIcon(assetRef *v2.AssetRef) UserTraitOption

func WithUserProfile

func WithUserProfile(profile map[string]interface{}) UserTraitOption

Jump to

Keyboard shortcuts

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