resource

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 11 Imported by: 154

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 GetExternalResourceTargetAppHint added in v0.6.6

func GetExternalResourceTargetAppHint(trait *v2.SecurityInsightTrait) string

GetExternalResourceTargetAppHint returns the app hint from a SecurityInsightTrait, or empty string if not an external resource target.

func GetExternalResourceTargetId added in v0.6.6

func GetExternalResourceTargetId(trait *v2.SecurityInsightTrait) string

GetExternalResourceTargetId returns the external ID from a SecurityInsightTrait, or empty string if not an external resource target.

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 GetResourceTarget added in v0.6.6

func GetResourceTarget(trait *v2.SecurityInsightTrait) *v2.ResourceId

GetResourceTarget returns the ResourceId from a SecurityInsightTrait, or nil if not a resource target.

func GetRoleTrait

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

GetRoleTrait attempts to return the RoleTrait instance on a resource.

func GetSecurityInsightTrait added in v0.6.6

func GetSecurityInsightTrait(resource *v2.Resource) (*v2.SecurityInsightTrait, error)

GetSecurityInsightTrait attempts to return the SecurityInsightTrait from a resource's annotations.

func GetUserTargetEmail added in v0.6.6

func GetUserTargetEmail(trait *v2.SecurityInsightTrait) string

GetUserTargetEmail returns the user email from a SecurityInsightTrait, or empty string if not a user target.

func GetUserTrait

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

GetUserTrait attempts to return the UserTrait instance on a resource.

func IsExternalResourceTarget added in v0.6.6

func IsExternalResourceTarget(trait *v2.SecurityInsightTrait) bool

IsExternalResourceTarget returns true if the insight targets an external resource.

func IsResourceTarget added in v0.6.6

func IsResourceTarget(trait *v2.SecurityInsightTrait) bool

IsResourceTarget returns true if the insight has a direct resource reference.

func IsSecurityInsightResource added in v0.6.6

func IsSecurityInsightResource(resourceType *v2.ResourceType) bool

IsSecurityInsightResource checks if a resource type has the TRAIT_SECURITY_INSIGHT trait.

func IsUserTarget added in v0.6.6

func IsUserTarget(trait *v2.SecurityInsightTrait) bool

IsUserTarget returns true if the insight targets a user.

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 NewExternalResourceSecurityInsightResource added in v0.6.6

func NewExternalResourceSecurityInsightResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	insightType string,
	value string,
	targetExternalId string,
	targetAppHint string,
	traitOpts []SecurityInsightTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewExternalResourceSecurityInsightResource creates a security insight resource targeting an external resource. Use this when the connector only has an external ID (e.g., ARN) and needs Uplift to resolve it.

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 NewResourceSecurityInsightResource added in v0.6.6

func NewResourceSecurityInsightResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	insightType string,
	value string,
	targetResourceId *v2.ResourceId,
	traitOpts []SecurityInsightTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewResourceSecurityInsightResource creates a security insight resource with a direct resource reference. Use this when the connector knows the actual resource (synced by this connector).

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 NewSecretResource added in v0.2.62

func NewSecretResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	traitOpts []SecretTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

func NewSecretTrait added in v0.2.62

func NewSecretTrait(opts ...SecretTraitOption) (*v2.SecretTrait, error)

NewSecretTrait creates a new `SecretTrait` with the given options.

func NewSecurityInsightTrait added in v0.6.6

func NewSecurityInsightTrait(insightType string, opts ...SecurityInsightTraitOption) (*v2.SecurityInsightTrait, error)

NewSecurityInsightTrait creates a new SecurityInsightTrait with the given insight type and options.

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 NewUserSecurityInsightResource added in v0.6.6

func NewUserSecurityInsightResource(
	name string,
	resourceType *v2.ResourceType,
	objectID interface{},
	insightType string,
	value string,
	userEmail string,
	traitOpts []SecurityInsightTraitOption,
	opts ...ResourceOption,
) (*v2.Resource, error)

NewUserSecurityInsightResource creates a security insight resource targeting a user by email. Use this when the insight should be resolved to a C1 User by Uplift.

func NewUserTrait

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

NewUserTrait creates a new `UserTrait`.

func SplitFullName added in v0.2.21

func SplitFullName(name string) (string, string)

SplitFullName looks for the first ` `, everything to the left is first name, everything to the right is last name.

Types

type AppTraitOption

type AppTraitOption func(gt *v2.AppTrait) error

func WithAppFlags added in v0.1.4

func WithAppFlags(flags ...v2.AppTrait_AppFlag) AppTraitOption

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 WithDescription added in v0.1.0

func WithDescription(description string) ResourceOption

func WithExternalID added in v0.1.15

func WithExternalID(externalID *v2.ExternalId) ResourceOption

func WithGroupTrait

func WithGroupTrait(opts ...GroupTraitOption) ResourceOption

func WithParentResourceID

func WithParentResourceID(parentResourceID *v2.ResourceId) ResourceOption

func WithRoleTrait

func WithRoleTrait(opts ...RoleTraitOption) ResourceOption

func WithSecretTrait added in v0.2.62

func WithSecretTrait(opts ...SecretTraitOption) ResourceOption

func WithSecurityInsightTrait added in v0.6.6

func WithSecurityInsightTrait(insightType string, opts ...SecurityInsightTraitOption) ResourceOption

WithSecurityInsightTrait adds or updates a SecurityInsightTrait annotation on a resource. The insightType parameter is required to ensure the trait is always valid. If the resource already has a SecurityInsightTrait, it will be updated with the provided options. If not, a new trait will be created with the given insightType.

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 SecretTraitOption added in v0.2.62

type SecretTraitOption func(t *v2.SecretTrait) error

func WithSecretCreatedAt added in v0.2.62

func WithSecretCreatedAt(createdAt time.Time) SecretTraitOption

func WithSecretCreatedByID added in v0.2.62

func WithSecretCreatedByID(createdById *v2.ResourceId) SecretTraitOption

func WithSecretExpiresAt added in v0.2.62

func WithSecretExpiresAt(expiresAt time.Time) SecretTraitOption

func WithSecretIdentityID added in v0.2.66

func WithSecretIdentityID(identityId *v2.ResourceId) SecretTraitOption

func WithSecretLastUsedAt added in v0.2.62

func WithSecretLastUsedAt(lastUsed time.Time) SecretTraitOption

type SecurityInsightTraitOption added in v0.6.6

type SecurityInsightTraitOption func(*v2.SecurityInsightTrait) error

SecurityInsightTraitOption is a functional option for configuring a SecurityInsightTrait.

func WithInsightExternalResourceTarget added in v0.6.6

func WithInsightExternalResourceTarget(externalId string, appHint string) SecurityInsightTraitOption

WithInsightExternalResourceTarget sets the external resource target for the insight. Use this when the connector only has an external ID (e.g., ARN) and needs Uplift to resolve it.

func WithInsightObservedAt added in v0.6.6

func WithInsightObservedAt(observedAt time.Time) SecurityInsightTraitOption

WithInsightObservedAt sets the observation timestamp for the insight.

func WithInsightResourceTarget added in v0.6.6

func WithInsightResourceTarget(resourceId *v2.ResourceId) SecurityInsightTraitOption

WithInsightResourceTarget sets a direct resource reference for the insight. Use this when the connector knows the actual resource (synced by this connector).

func WithInsightType added in v0.6.6

func WithInsightType(insightType string) SecurityInsightTraitOption

WithInsightType sets the insight type. This is typically set via NewSecurityInsightTrait, but can be used to override or update the type on an existing trait.

func WithInsightUserTarget added in v0.6.6

func WithInsightUserTarget(email string) SecurityInsightTraitOption

WithInsightUserTarget sets the user target (by email) for the insight. Use this when the insight should be resolved to a C1 User by Uplift.

func WithInsightValue added in v0.6.6

func WithInsightValue(value string) SecurityInsightTraitOption

WithInsightValue sets the value of the security insight.

type SyncOpAttrs added in v0.5.0

type SyncOpAttrs struct {
	Session   sessions.SessionStore
	SyncID    string
	PageToken pagination.Token
}

type SyncOpResults added in v0.5.0

type SyncOpResults struct {
	NextPageToken string
	Annotations   annotations.Annotations
}

type UserTraitOption

type UserTraitOption func(ut *v2.UserTrait) error

func WithAccountType

func WithAccountType(accountType v2.UserTrait_AccountType) UserTraitOption

func WithCreatedAt added in v0.1.14

func WithCreatedAt(createdAt time.Time) UserTraitOption

func WithDetailedStatus added in v0.1.29

func WithDetailedStatus(status v2.UserTrait_Status_Status, details string) UserTraitOption

func WithEmail

func WithEmail(email string, primary bool) UserTraitOption

func WithEmployeeID added in v0.2.88

func WithEmployeeID(employeeIDs ...string) UserTraitOption

func WithLastLogin added in v0.1.14

func WithLastLogin(lastLogin time.Time) UserTraitOption

func WithMFAStatus added in v0.1.14

func WithMFAStatus(mfaStatus *v2.UserTrait_MFAStatus) UserTraitOption

func WithSSOStatus added in v0.1.14

func WithSSOStatus(ssoStatus *v2.UserTrait_SSOStatus) UserTraitOption

func WithStatus

func WithStatus(status v2.UserTrait_Status_Status) UserTraitOption

func WithStructuredName added in v0.2.67

func WithStructuredName(structuredName *v2.UserTrait_StructuredName) UserTraitOption

func WithUserIcon

func WithUserIcon(assetRef *v2.AssetRef) UserTraitOption

func WithUserLogin added in v0.1.7

func WithUserLogin(login string, aliases ...string) 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