db

package
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadPropVersion = errors.New("unexpected property version")

ErrBadPropVersion is returned when a property has an unexpected version

View Source
var ErrParseData = errors.New("unable to parse SQL data")

ErrParseData signifies that an error occurred while parsing SQL data

Functions

func CalculateProjectHierarchyOffset

func CalculateProjectHierarchyOffset(hierarchy int) int

CalculateProjectHierarchyOffset will calculate the offset for the hierarchy in the returned array from GetChildrenProjects and GetParentProjects. This is because the calling project is also returned.

func ErrIsUniqueViolation

func ErrIsUniqueViolation(err error) bool

ErrIsUniqueViolation returns true if the error is a unique violation

func PropValueFromDbV1

func PropValueFromDbV1(rawValue json.RawMessage) (any, error)

PropValueFromDbV1 deserializes a property value from a JSON byte slice

func PropValueToDbV1

func PropValueToDbV1(value any) (json.RawMessage, error)

PropValueToDbV1 serializes a property value to a JSON byte slice

func WithTransaction

func WithTransaction[T any](store Store, fn func(querier ExtendQuerier) (T, error)) (result T, err error)

WithTransaction wraps an operation in a new DB transaction. Ideally this would be a method of the Store interface, but Go's generics do not allow for generic methods :(

Types

type ActionType

type ActionType string
const (
	ActionTypeOn     ActionType = "on"
	ActionTypeOff    ActionType = "off"
	ActionTypeDryRun ActionType = "dry_run"
)

func (*ActionType) Scan

func (e *ActionType) Scan(src interface{}) error

type AlertEvent

type AlertEvent struct {
	ID           uuid.UUID        `json:"id"`
	EvaluationID uuid.UUID        `json:"evaluation_id"`
	Status       AlertStatusTypes `json:"status"`
	Details      string           `json:"details"`
	Metadata     json.RawMessage  `json:"metadata"`
	CreatedAt    time.Time        `json:"created_at"`
}

type AlertStatusTypes

type AlertStatusTypes string
const (
	AlertStatusTypesOn           AlertStatusTypes = "on"
	AlertStatusTypesOff          AlertStatusTypes = "off"
	AlertStatusTypesError        AlertStatusTypes = "error"
	AlertStatusTypesSkipped      AlertStatusTypes = "skipped"
	AlertStatusTypesNotAvailable AlertStatusTypes = "not_available"
)

func (*AlertStatusTypes) Scan

func (e *AlertStatusTypes) Scan(src interface{}) error

type Artifact

type Artifact struct {
	ID                 uuid.UUID     `json:"id"`
	RepositoryID       uuid.NullUUID `json:"repository_id"`
	ArtifactName       string        `json:"artifact_name"`
	ArtifactType       string        `json:"artifact_type"`
	ArtifactVisibility string        `json:"artifact_visibility"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ProjectID          uuid.UUID     `json:"project_id"`
	ProviderID         uuid.UUID     `json:"provider_id"`
	ProviderName       string        `json:"provider_name"`
}

type AuthorizationFlow

type AuthorizationFlow string
const (
	AuthorizationFlowUserInput                   AuthorizationFlow = "user_input"
	AuthorizationFlowOauth2AuthorizationCodeFlow AuthorizationFlow = "oauth2_authorization_code_flow"
	AuthorizationFlowGithubAppFlow               AuthorizationFlow = "github_app_flow"
	AuthorizationFlowNone                        AuthorizationFlow = "none"
)

func (*AuthorizationFlow) Scan

func (e *AuthorizationFlow) Scan(src interface{}) error

type BulkGetProfilesByIDRow

type BulkGetProfilesByIDRow struct {
	Profile               Profile           `json:"profile"`
	ProfilesWithSelectors []ProfileSelector `json:"profiles_with_selectors"`
}

type Bundle

type Bundle struct {
	ID        uuid.UUID `json:"id"`
	Namespace string    `json:"namespace"`
	Name      string    `json:"name"`
}

type CountProfilesByEntityTypeRow

type CountProfilesByEntityTypeRow struct {
	NumProfiles   int64    `json:"num_profiles"`
	ProfileEntity Entities `json:"profile_entity"`
}

type CreateEntityParams

type CreateEntityParams struct {
	EntityType     Entities      `json:"entity_type"`
	Name           string        `json:"name"`
	ProjectID      uuid.UUID     `json:"project_id"`
	ProviderID     uuid.UUID     `json:"provider_id"`
	OriginatedFrom uuid.NullUUID `json:"originated_from"`
}

type CreateEntityWithIDParams

type CreateEntityWithIDParams struct {
	ID             uuid.UUID     `json:"id"`
	EntityType     Entities      `json:"entity_type"`
	Name           string        `json:"name"`
	ProjectID      uuid.UUID     `json:"project_id"`
	ProviderID     uuid.UUID     `json:"provider_id"`
	OriginatedFrom uuid.NullUUID `json:"originated_from"`
}

type CreateInvitationParams

type CreateInvitationParams struct {
	Code    string    `json:"code"`
	Email   string    `json:"email"`
	Role    string    `json:"role"`
	Project uuid.UUID `json:"project"`
	Sponsor int32     `json:"sponsor"`
}

type CreateOrEnsureEntityByIDParams

type CreateOrEnsureEntityByIDParams struct {
	ID             uuid.UUID     `json:"id"`
	EntityType     Entities      `json:"entity_type"`
	Name           string        `json:"name"`
	ProjectID      uuid.UUID     `json:"project_id"`
	ProviderID     uuid.UUID     `json:"provider_id"`
	OriginatedFrom uuid.NullUUID `json:"originated_from"`
}

type CreateOrganizationParams

type CreateOrganizationParams struct {
	Name     string          `json:"name"`
	Metadata json.RawMessage `json:"metadata"`
}

type CreateProfileForEntityParams

type CreateProfileForEntityParams struct {
	Entity          Entities        `json:"entity"`
	ProfileID       uuid.UUID       `json:"profile_id"`
	ContextualRules json.RawMessage `json:"contextual_rules"`
}

type CreateProfileParams

type CreateProfileParams struct {
	ProjectID      uuid.UUID      `json:"project_id"`
	Remediate      NullActionType `json:"remediate"`
	Alert          NullActionType `json:"alert"`
	Name           string         `json:"name"`
	SubscriptionID uuid.NullUUID  `json:"subscription_id"`
	DisplayName    string         `json:"display_name"`
	Labels         []string       `json:"labels"`
}

type CreateProjectParams

type CreateProjectParams struct {
	Name     string          `json:"name"`
	ParentID uuid.NullUUID   `json:"parent_id"`
	Metadata json.RawMessage `json:"metadata"`
}

type CreateProjectWithIDParams

type CreateProjectWithIDParams struct {
	ID       uuid.UUID       `json:"id"`
	Name     string          `json:"name"`
	Metadata json.RawMessage `json:"metadata"`
}

type CreateProviderParams

type CreateProviderParams struct {
	Name       string              `json:"name"`
	ProjectID  uuid.UUID           `json:"project_id"`
	Class      ProviderClass       `json:"class"`
	Implements []ProviderType      `json:"implements"`
	Definition json.RawMessage     `json:"definition"`
	AuthFlows  []AuthorizationFlow `json:"auth_flows"`
}

type CreateRepositoryParams

type CreateRepositoryParams struct {
	Provider      string         `json:"provider"`
	ProjectID     uuid.UUID      `json:"project_id"`
	RepoOwner     string         `json:"repo_owner"`
	RepoName      string         `json:"repo_name"`
	RepoID        int64          `json:"repo_id"`
	IsPrivate     bool           `json:"is_private"`
	IsFork        bool           `json:"is_fork"`
	WebhookID     sql.NullInt64  `json:"webhook_id"`
	WebhookUrl    string         `json:"webhook_url"`
	DeployUrl     string         `json:"deploy_url"`
	CloneUrl      string         `json:"clone_url"`
	DefaultBranch sql.NullString `json:"default_branch"`
	License       sql.NullString `json:"license"`
	ProviderID    uuid.UUID      `json:"provider_id"`
}

type CreateRuleTypeParams

type CreateRuleTypeParams struct {
	Name                string          `json:"name"`
	ProjectID           uuid.UUID       `json:"project_id"`
	Description         string          `json:"description"`
	Guidance            string          `json:"guidance"`
	Definition          json.RawMessage `json:"definition"`
	SeverityValue       Severity        `json:"severity_value"`
	SubscriptionID      uuid.NullUUID   `json:"subscription_id"`
	DisplayName         string          `json:"display_name"`
	ReleasePhase        ReleaseStatus   `json:"release_phase"`
	ShortFailureMessage string          `json:"short_failure_message"`
}

type CreateSelectorParams

type CreateSelectorParams struct {
	ProfileID uuid.UUID    `json:"profile_id"`
	Entity    NullEntities `json:"entity"`
	Selector  string       `json:"selector"`
	Comment   string       `json:"comment"`
}

type CreateSessionStateParams

type CreateSessionStateParams struct {
	Provider          string                `json:"provider"`
	ProjectID         uuid.UUID             `json:"project_id"`
	RemoteUser        sql.NullString        `json:"remote_user"`
	SessionState      string                `json:"session_state"`
	OwnerFilter       sql.NullString        `json:"owner_filter"`
	ProviderConfig    []byte                `json:"provider_config"`
	EncryptedRedirect pqtype.NullRawMessage `json:"encrypted_redirect"`
}

type CreateSubscriptionParams

type CreateSubscriptionParams struct {
	ProjectID      uuid.UUID `json:"project_id"`
	BundleID       uuid.UUID `json:"bundle_id"`
	CurrentVersion string    `json:"current_version"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DeleteEntityParams

type DeleteEntityParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type DeleteNonUpdatedRulesParams

type DeleteNonUpdatedRulesParams struct {
	ProfileID  uuid.UUID   `json:"profile_id"`
	EntityType Entities    `json:"entity_type"`
	UpdatedIds []uuid.UUID `json:"updated_ids"`
}

type DeleteProfileForEntityParams

type DeleteProfileForEntityParams struct {
	ProfileID uuid.UUID `json:"profile_id"`
	Entity    Entities  `json:"entity"`
}

type DeleteProfileParams

type DeleteProfileParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type DeleteProjectRow

type DeleteProjectRow struct {
	ID        uuid.UUID       `json:"id"`
	Name      string          `json:"name"`
	Metadata  json.RawMessage `json:"metadata"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
	ParentID  uuid.NullUUID   `json:"parent_id"`
}

type DeletePropertyParams

type DeletePropertyParams struct {
	EntityID uuid.UUID `json:"entity_id"`
	Key      string    `json:"key"`
}

type DeleteProviderParams

type DeleteProviderParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type DeleteSessionStateByProjectIDParams

type DeleteSessionStateByProjectIDParams struct {
	Provider  string    `json:"provider"`
	ProjectID uuid.UUID `json:"project_id"`
}

type EnqueueFlushParams

type EnqueueFlushParams struct {
	Entity           Entities  `json:"entity"`
	ProjectID        uuid.UUID `json:"project_id"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
}

type Entities

type Entities string
const (
	EntitiesRepository       Entities = "repository"
	EntitiesBuildEnvironment Entities = "build_environment"
	EntitiesArtifact         Entities = "artifact"
	EntitiesPullRequest      Entities = "pull_request"
	EntitiesRelease          Entities = "release"
	EntitiesPipelineRun      Entities = "pipeline_run"
	EntitiesTaskRun          Entities = "task_run"
	EntitiesBuild            Entities = "build"
)

func (*Entities) Scan

func (e *Entities) Scan(src interface{}) error

type Entitlement

type Entitlement struct {
	ID        uuid.UUID `json:"id"`
	Feature   string    `json:"feature"`
	ProjectID uuid.UUID `json:"project_id"`
	CreatedAt time.Time `json:"created_at"`
}

type EntityExecutionLock

type EntityExecutionLock struct {
	ID               uuid.UUID `json:"id"`
	Entity           Entities  `json:"entity"`
	LockedBy         uuid.UUID `json:"locked_by"`
	LastLockTime     time.Time `json:"last_lock_time"`
	ProjectID        uuid.UUID `json:"project_id"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
}

type EntityInstance

type EntityInstance struct {
	ID             uuid.UUID     `json:"id"`
	EntityType     Entities      `json:"entity_type"`
	Name           string        `json:"name"`
	ProjectID      uuid.UUID     `json:"project_id"`
	ProviderID     uuid.UUID     `json:"provider_id"`
	CreatedAt      time.Time     `json:"created_at"`
	OriginatedFrom uuid.NullUUID `json:"originated_from"`
}

type EntityProfile

type EntityProfile struct {
	ID              uuid.UUID       `json:"id"`
	Entity          Entities        `json:"entity"`
	ProfileID       uuid.UUID       `json:"profile_id"`
	ContextualRules json.RawMessage `json:"contextual_rules"`
	CreatedAt       time.Time       `json:"created_at"`
	UpdatedAt       time.Time       `json:"updated_at"`
	Migrated        bool            `json:"migrated"`
}

type EvalStatusTypes

type EvalStatusTypes string
const (
	EvalStatusTypesSuccess EvalStatusTypes = "success"
	EvalStatusTypesFailure EvalStatusTypes = "failure"
	EvalStatusTypesError   EvalStatusTypes = "error"
	EvalStatusTypesSkipped EvalStatusTypes = "skipped"
	EvalStatusTypesPending EvalStatusTypes = "pending"
)

func (*EvalStatusTypes) Scan

func (e *EvalStatusTypes) Scan(src interface{}) error

type EvaluationRuleEntity

type EvaluationRuleEntity struct {
	ID               uuid.UUID     `json:"id"`
	RuleID           uuid.UUID     `json:"rule_id"`
	RepositoryID     uuid.NullUUID `json:"repository_id"`
	PullRequestID    uuid.NullUUID `json:"pull_request_id"`
	ArtifactID       uuid.NullUUID `json:"artifact_id"`
	EntityType       Entities      `json:"entity_type"`
	EntityInstanceID uuid.UUID     `json:"entity_instance_id"`
}

type EvaluationStatus

type EvaluationStatus struct {
	ID             uuid.UUID       `json:"id"`
	RuleEntityID   uuid.UUID       `json:"rule_entity_id"`
	Status         EvalStatusTypes `json:"status"`
	Details        string          `json:"details"`
	EvaluationTime time.Time       `json:"evaluation_time"`
	Checkpoint     json.RawMessage `json:"checkpoint"`
}

type ExtendQuerier

type ExtendQuerier interface {
	Querier
	GetRuleEvaluationByProfileIdAndRuleType(ctx context.Context, profileID uuid.UUID,
		ruleName sql.NullString, entityID uuid.UUID, ruleTypeName sql.NullString) (*ListRuleEvaluationsByProfileIdRow, error)
	UpsertPropertyValueV1(ctx context.Context, params UpsertPropertyValueV1Params) (Property, error)
	GetPropertyValueV1(ctx context.Context, entityID uuid.UUID, key string) (PropertyValueV1, error)
	GetAllPropertyValuesV1(ctx context.Context, entityID uuid.UUID) ([]PropertyValueV1, error)
	GetTypedEntitiesByPropertyV1(
		ctx context.Context, entType Entities, key string, value any, opts GetTypedEntitiesOptions,
	) ([]EntityInstance, error)
}

ExtendQuerier extends the Querier interface with custom queries

type Feature

type Feature struct {
	Name      string          `json:"name"`
	Settings  json.RawMessage `json:"settings"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type FindProvidersParams

type FindProvidersParams struct {
	Projects []uuid.UUID      `json:"projects"`
	Trait    NullProviderType `json:"trait"`
	Name     sql.NullString   `json:"name"`
}

type FlushCache

type FlushCache struct {
	ID               uuid.UUID `json:"id"`
	Entity           Entities  `json:"entity"`
	QueuedAt         time.Time `json:"queued_at"`
	ProjectID        uuid.UUID `json:"project_id"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
}

type GetAccessTokenByEnrollmentNonceParams

type GetAccessTokenByEnrollmentNonceParams struct {
	ProjectID       uuid.UUID      `json:"project_id"`
	EnrollmentNonce sql.NullString `json:"enrollment_nonce"`
}

type GetAccessTokenByProjectIDParams

type GetAccessTokenByProjectIDParams struct {
	Provider  string    `json:"provider"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetAccessTokenSinceDateParams

type GetAccessTokenSinceDateParams struct {
	Provider  string    `json:"provider"`
	ProjectID uuid.UUID `json:"project_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type GetArtifactByIDParams

type GetArtifactByIDParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetArtifactByNameParams

type GetArtifactByNameParams struct {
	RepositoryID uuid.NullUUID `json:"repository_id"`
	ProjectID    uuid.UUID     `json:"project_id"`
	ArtifactName string        `json:"artifact_name"`
}

type GetBundleParams

type GetBundleParams struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

type GetChildrenProjectsRow

type GetChildrenProjectsRow struct {
	ID        uuid.UUID       `json:"id"`
	Name      string          `json:"name"`
	Metadata  json.RawMessage `json:"metadata"`
	ParentID  uuid.NullUUID   `json:"parent_id"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type GetEntitiesByTypeParams

type GetEntitiesByTypeParams struct {
	EntityType Entities    `json:"entity_type"`
	ProviderID uuid.UUID   `json:"provider_id"`
	Projects   []uuid.UUID `json:"projects"`
}

type GetEntityByNameParams

type GetEntityByNameParams struct {
	ProjectID  uuid.UUID `json:"project_id"`
	EntityType Entities  `json:"entity_type"`
	Name       string    `json:"name"`
	ProviderID uuid.UUID `json:"provider_id"`
}

type GetEvaluationHistoryParams

type GetEvaluationHistoryParams struct {
	EvaluationID uuid.UUID `json:"evaluation_id"`
	ProjectID    uuid.UUID `json:"project_id"`
}

type GetEvaluationHistoryRow

type GetEvaluationHistoryRow struct {
	EvaluationID       uuid.UUID                  `json:"evaluation_id"`
	EvaluatedAt        time.Time                  `json:"evaluated_at"`
	EntityType         Entities                   `json:"entity_type"`
	EntityID           uuid.UUID                  `json:"entity_id"`
	EntityName         string                     `json:"entity_name"`
	ProjectID          uuid.UUID                  `json:"project_id"`
	RuleType           string                     `json:"rule_type"`
	RuleName           string                     `json:"rule_name"`
	RuleSeverity       Severity                   `json:"rule_severity"`
	ProfileName        string                     `json:"profile_name"`
	EvaluationStatus   EvalStatusTypes            `json:"evaluation_status"`
	EvaluationDetails  string                     `json:"evaluation_details"`
	RemediationStatus  NullRemediationStatusTypes `json:"remediation_status"`
	RemediationDetails sql.NullString             `json:"remediation_details"`
	AlertStatus        NullAlertStatusTypes       `json:"alert_status"`
	AlertDetails       sql.NullString             `json:"alert_details"`
}

type GetFeatureInProjectParams

type GetFeatureInProjectParams struct {
	ProjectID uuid.UUID `json:"project_id"`
	Feature   string    `json:"feature"`
}

type GetInstallationIDByEnrollmentNonceParams

type GetInstallationIDByEnrollmentNonceParams struct {
	ProjectID       uuid.NullUUID  `json:"project_id"`
	EnrollmentNonce sql.NullString `json:"enrollment_nonce"`
}

type GetInvitationByCodeRow

type GetInvitationByCodeRow struct {
	Code            string    `json:"code"`
	Email           string    `json:"email"`
	Role            string    `json:"role"`
	Project         uuid.UUID `json:"project"`
	Sponsor         int32     `json:"sponsor"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	IdentitySubject string    `json:"identity_subject"`
}

type GetInvitationsByEmailAndProjectParams

type GetInvitationsByEmailAndProjectParams struct {
	Email   string    `json:"email"`
	Project uuid.UUID `json:"project"`
}

type GetInvitationsByEmailAndProjectRow

type GetInvitationsByEmailAndProjectRow struct {
	Code            string    `json:"code"`
	Email           string    `json:"email"`
	Role            string    `json:"role"`
	Project         uuid.UUID `json:"project"`
	Sponsor         int32     `json:"sponsor"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	IdentitySubject string    `json:"identity_subject"`
}

type GetInvitationsByEmailRow

type GetInvitationsByEmailRow struct {
	Code            string    `json:"code"`
	Email           string    `json:"email"`
	Role            string    `json:"role"`
	Project         uuid.UUID `json:"project"`
	Sponsor         int32     `json:"sponsor"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	IdentitySubject string    `json:"identity_subject"`
}

type GetLatestEvalStateForRuleEntityParams

type GetLatestEvalStateForRuleEntityParams struct {
	RuleID           uuid.UUID `json:"rule_id"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
}

type GetParentProjectsUntilParams

type GetParentProjectsUntilParams struct {
	ID   uuid.UUID `json:"id"`
	ID_2 uuid.UUID `json:"id_2"`
}

type GetProfileByIDAndLockParams

type GetProfileByIDAndLockParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetProfileByIDParams

type GetProfileByIDParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetProfileByNameAndLockParams

type GetProfileByNameAndLockParams struct {
	ProjectID uuid.UUID `json:"project_id"`
	Name      string    `json:"name"`
}

type GetProfileByProjectAndIDParams

type GetProfileByProjectAndIDParams struct {
	ProjectID uuid.UUID `json:"project_id"`
	ID        uuid.UUID `json:"id"`
}

type GetProfileByProjectAndIDRow

type GetProfileByProjectAndIDRow struct {
	Profile                   Profile                   `json:"profile"`
	ProfilesWithEntityProfile ProfilesWithEntityProfile `json:"profiles_with_entity_profile"`
	ProfilesWithSelectors     []ProfileSelector         `json:"profiles_with_selectors"`
}

type GetProfileByProjectAndNameParams

type GetProfileByProjectAndNameParams struct {
	ProjectID uuid.UUID `json:"project_id"`
	Name      string    `json:"name"`
}

type GetProfileByProjectAndNameRow

type GetProfileByProjectAndNameRow struct {
	Profile                   Profile                   `json:"profile"`
	ProfilesWithEntityProfile ProfilesWithEntityProfile `json:"profiles_with_entity_profile"`
	ProfilesWithSelectors     []ProfileSelector         `json:"profiles_with_selectors"`
}

type GetProfileStatusByIdAndProjectParams

type GetProfileStatusByIdAndProjectParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetProfileStatusByIdAndProjectRow

type GetProfileStatusByIdAndProjectRow struct {
	ID            uuid.UUID       `json:"id"`
	Name          string          `json:"name"`
	ProfileStatus EvalStatusTypes `json:"profile_status"`
	LastUpdated   time.Time       `json:"last_updated"`
}

type GetProfileStatusByNameAndProjectParams

type GetProfileStatusByNameAndProjectParams struct {
	ProjectID uuid.UUID `json:"project_id"`
	Name      string    `json:"name"`
}

type GetProfileStatusByNameAndProjectRow

type GetProfileStatusByNameAndProjectRow struct {
	ID            uuid.UUID       `json:"id"`
	Name          string          `json:"name"`
	ProfileStatus EvalStatusTypes `json:"profile_status"`
	LastUpdated   time.Time       `json:"last_updated"`
}

type GetProfileStatusByProjectRow

type GetProfileStatusByProjectRow struct {
	ID            uuid.UUID       `json:"id"`
	Name          string          `json:"name"`
	ProfileStatus EvalStatusTypes `json:"profile_status"`
	LastUpdated   time.Time       `json:"last_updated"`
}

type GetProjectIDBySessionStateRow

type GetProjectIDBySessionStateRow struct {
	Provider          string                `json:"provider"`
	ProjectID         uuid.UUID             `json:"project_id"`
	RemoteUser        sql.NullString        `json:"remote_user"`
	OwnerFilter       sql.NullString        `json:"owner_filter"`
	ProviderConfig    []byte                `json:"provider_config"`
	RedirectUrl       sql.NullString        `json:"redirect_url"`
	EncryptedRedirect pqtype.NullRawMessage `json:"encrypted_redirect"`
}

type GetPropertyParams

type GetPropertyParams struct {
	EntityID uuid.UUID `json:"entity_id"`
	Key      string    `json:"key"`
}

type GetProviderByIDAndProjectParams

type GetProviderByIDAndProjectParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetProviderByNameParams

type GetProviderByNameParams struct {
	Name     string      `json:"name"`
	Projects []uuid.UUID `json:"projects"`
}

type GetRepositoryByIDAndProjectParams

type GetRepositoryByIDAndProjectParams struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetRepositoryByRepoNameParams

type GetRepositoryByRepoNameParams struct {
	RepoOwner string         `json:"repo_owner"`
	RepoName  string         `json:"repo_name"`
	ProjectID uuid.UUID      `json:"project_id"`
	Provider  sql.NullString `json:"provider"`
}

type GetRuleInstancesEntityInProjectsParams

type GetRuleInstancesEntityInProjectsParams struct {
	EntityType Entities    `json:"entity_type"`
	ProjectIds []uuid.UUID `json:"project_ids"`
}

type GetRuleTypeByNameParams

type GetRuleTypeByNameParams struct {
	Projects []uuid.UUID `json:"projects"`
	Name     string      `json:"name"`
}

type GetRuleTypeIDByRuleNameEntityProfileParams

type GetRuleTypeIDByRuleNameEntityProfileParams struct {
	Name       string    `json:"name"`
	EntityType Entities  `json:"entity_type"`
	ProfileID  uuid.UUID `json:"profile_id"`
}

type GetRuleTypesByEntityInHierarchyParams

type GetRuleTypesByEntityInHierarchyParams struct {
	EntityType Entities    `json:"entity_type"`
	Projects   []uuid.UUID `json:"projects"`
}

type GetSubscriptionByProjectBundleParams

type GetSubscriptionByProjectBundleParams struct {
	Namespace string    `json:"namespace"`
	Name      string    `json:"name"`
	ProjectID uuid.UUID `json:"project_id"`
}

type GetTypedEntitiesByPropertyParams

type GetTypedEntitiesByPropertyParams struct {
	EntityType Entities        `json:"entity_type"`
	ProjectID  uuid.UUID       `json:"project_id"`
	ProviderID uuid.UUID       `json:"provider_id"`
	Key        string          `json:"key"`
	Value      json.RawMessage `json:"value"`
}

type GetTypedEntitiesOptions

type GetTypedEntitiesOptions struct {
	ProjectID  uuid.UUID
	ProviderID uuid.UUID
}

GetTypedEntitiesOptions provides options for GetTypedEntitiesByPropertyV1

type InsertAlertEventParams

type InsertAlertEventParams struct {
	EvaluationID uuid.UUID        `json:"evaluation_id"`
	Status       AlertStatusTypes `json:"status"`
	Details      string           `json:"details"`
	Metadata     json.RawMessage  `json:"metadata"`
}

type InsertEvaluationRuleEntityParams

type InsertEvaluationRuleEntityParams struct {
	RuleID           uuid.UUID `json:"rule_id"`
	EntityType       Entities  `json:"entity_type"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
}

type InsertEvaluationStatusParams

type InsertEvaluationStatusParams struct {
	RuleEntityID uuid.UUID       `json:"rule_entity_id"`
	Status       EvalStatusTypes `json:"status"`
	Details      string          `json:"details"`
	Checkpoint   json.RawMessage `json:"checkpoint"`
}

type InsertRemediationEventParams

type InsertRemediationEventParams struct {
	EvaluationID uuid.UUID              `json:"evaluation_id"`
	Status       RemediationStatusTypes `json:"status"`
	Details      string                 `json:"details"`
	Metadata     json.RawMessage        `json:"metadata"`
}

type LatestEvaluationStatus

type LatestEvaluationStatus struct {
	RuleEntityID        uuid.UUID `json:"rule_entity_id"`
	EvaluationHistoryID uuid.UUID `json:"evaluation_history_id"`
	ProfileID           uuid.UUID `json:"profile_id"`
}

type ListEvaluationHistoryParams

type ListEvaluationHistoryParams struct {
	Next            sql.NullTime             `json:"next"`
	Prev            sql.NullTime             `json:"prev"`
	Entitytypes     []Entities               `json:"entitytypes"`
	Entitynames     []string                 `json:"entitynames"`
	Profilenames    []string                 `json:"profilenames"`
	Remediations    []RemediationStatusTypes `json:"remediations"`
	Alerts          []AlertStatusTypes       `json:"alerts"`
	Statuses        []EvalStatusTypes        `json:"statuses"`
	Notentitytypes  []Entities               `json:"notentitytypes"`
	Notentitynames  []string                 `json:"notentitynames"`
	Notprofilenames []string                 `json:"notprofilenames"`
	Notremediations []RemediationStatusTypes `json:"notremediations"`
	Notalerts       []AlertStatusTypes       `json:"notalerts"`
	Notstatuses     []EvalStatusTypes        `json:"notstatuses"`
	Fromts          sql.NullTime             `json:"fromts"`
	Tots            sql.NullTime             `json:"tots"`
	Projectid       uuid.UUID                `json:"projectid"`
	Size            int64                    `json:"size"`
}

type ListEvaluationHistoryRow

type ListEvaluationHistoryRow struct {
	EvaluationID       uuid.UUID                  `json:"evaluation_id"`
	EvaluatedAt        time.Time                  `json:"evaluated_at"`
	EntityType         Entities                   `json:"entity_type"`
	EntityID           uuid.UUID                  `json:"entity_id"`
	ProjectID          uuid.UUID                  `json:"project_id"`
	RuleType           string                     `json:"rule_type"`
	RuleName           string                     `json:"rule_name"`
	RuleSeverity       Severity                   `json:"rule_severity"`
	ProfileName        string                     `json:"profile_name"`
	EvaluationStatus   EvalStatusTypes            `json:"evaluation_status"`
	EvaluationDetails  string                     `json:"evaluation_details"`
	RemediationStatus  NullRemediationStatusTypes `json:"remediation_status"`
	RemediationDetails sql.NullString             `json:"remediation_details"`
	AlertStatus        NullAlertStatusTypes       `json:"alert_status"`
	AlertDetails       sql.NullString             `json:"alert_details"`
}

type ListEvaluationHistoryStaleRecordsParams

type ListEvaluationHistoryStaleRecordsParams struct {
	Threshold time.Time `json:"threshold"`
	Size      int32     `json:"size"`
}

type ListEvaluationHistoryStaleRecordsRow

type ListEvaluationHistoryStaleRecordsRow struct {
	EvaluationTime time.Time `json:"evaluation_time"`
	ID             uuid.UUID `json:"id"`
	RuleID         uuid.UUID `json:"rule_id"`
	EntityType     Entities  `json:"entity_type"`
	EntityID       uuid.UUID `json:"entity_id"`
}

type ListInvitationsForProjectRow

type ListInvitationsForProjectRow struct {
	Email           string    `json:"email"`
	Role            string    `json:"role"`
	IdentitySubject string    `json:"identity_subject"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type ListOldestRuleEvaluationsByRepositoryIdRow

type ListOldestRuleEvaluationsByRepositoryIdRow struct {
	RepositoryID      uuid.UUID `json:"repository_id"`
	OldestLastUpdated time.Time `json:"oldest_last_updated"`
}

type ListOrganizationsParams

type ListOrganizationsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListProfilesByProjectIDAndLabelParams

type ListProfilesByProjectIDAndLabelParams struct {
	ProjectID     uuid.UUID `json:"project_id"`
	IncludeLabels []string  `json:"include_labels"`
	ExcludeLabels []string  `json:"exclude_labels"`
}

func (*ListProfilesByProjectIDAndLabelParams) LabelsFromFilter

func (lp *ListProfilesByProjectIDAndLabelParams) LabelsFromFilter(filter string)

LabelsFromFilter parses the filter string and populates the IncludeLabels and ExcludeLabels fields

type ListProfilesByProjectIDAndLabelRow

type ListProfilesByProjectIDAndLabelRow struct {
	Profile                   Profile                   `json:"profile"`
	ProfilesWithEntityProfile ProfilesWithEntityProfile `json:"profiles_with_entity_profile"`
	ProfilesWithSelectors     []ProfileSelector         `json:"profiles_with_selectors"`
}

func (ListProfilesByProjectIDAndLabelRow) GetContextualRules

GetContextualRules returns the contextual rules

func (ListProfilesByProjectIDAndLabelRow) GetEntityProfile

func (r ListProfilesByProjectIDAndLabelRow) GetEntityProfile() NullEntities

GetEntityProfile returns the entity profile

func (ListProfilesByProjectIDAndLabelRow) GetProfile

GetProfile returns the profile

func (ListProfilesByProjectIDAndLabelRow) GetSelectors

GetSelectors returns the selectors

type ListProvidersByProjectIDPaginatedParams

type ListProvidersByProjectIDPaginatedParams struct {
	ProjectID uuid.UUID    `json:"project_id"`
	CreatedAt sql.NullTime `json:"created_at"`
	Limit     int32        `json:"limit"`
}

type ListRegisteredRepositoriesByProjectIDAndProviderParams

type ListRegisteredRepositoriesByProjectIDAndProviderParams struct {
	ProjectID uuid.UUID      `json:"project_id"`
	Provider  sql.NullString `json:"provider"`
}

type ListRepositoriesAfterIDParams

type ListRepositoriesAfterIDParams struct {
	ID    uuid.UUID `json:"id"`
	Limit int64     `json:"limit"`
}

type ListRepositoriesByProjectIDParams

type ListRepositoriesByProjectIDParams struct {
	ProjectID uuid.UUID      `json:"project_id"`
	RepoID    sql.NullInt64  `json:"repo_id"`
	Provider  sql.NullString `json:"provider"`
	Limit     sql.NullInt64  `json:"limit"`
}

type ListRuleEvaluationsByProfileIdParams

type ListRuleEvaluationsByProfileIdParams struct {
	ProfileID    uuid.UUID      `json:"profile_id"`
	EntityID     uuid.NullUUID  `json:"entity_id"`
	RuleTypeName sql.NullString `json:"rule_type_name"`
	RuleName     sql.NullString `json:"rule_name"`
}

type ListRuleEvaluationsByProfileIdRow

type ListRuleEvaluationsByProfileIdRow struct {
	EvalStatus            EvalStatusTypes        `json:"eval_status"`
	EvalLastUpdated       time.Time              `json:"eval_last_updated"`
	EvalDetails           string                 `json:"eval_details"`
	RemStatus             RemediationStatusTypes `json:"rem_status"`
	RemDetails            string                 `json:"rem_details"`
	RemMetadata           json.RawMessage        `json:"rem_metadata"`
	RemLastUpdated        time.Time              `json:"rem_last_updated"`
	AlertStatus           AlertStatusTypes       `json:"alert_status"`
	AlertDetails          string                 `json:"alert_details"`
	AlertMetadata         json.RawMessage        `json:"alert_metadata"`
	AlertLastUpdated      time.Time              `json:"alert_last_updated"`
	RuleEvaluationID      uuid.UUID              `json:"rule_evaluation_id"`
	EntityType            Entities               `json:"entity_type"`
	RuleName              string                 `json:"rule_name"`
	Provider              string                 `json:"provider"`
	RuleTypeName          string                 `json:"rule_type_name"`
	RuleTypeSeverityValue Severity               `json:"rule_type_severity_value"`
	RuleTypeID            uuid.UUID              `json:"rule_type_id"`
	RuleTypeGuidance      string                 `json:"rule_type_guidance"`
	RuleTypeDisplayName   string                 `json:"rule_type_display_name"`
	EntityID              uuid.UUID              `json:"entity_id"`
	ProjectID             uuid.UUID              `json:"project_id"`
	RuleTypeReleasePhase  ReleaseStatus          `json:"rule_type_release_phase"`
}

type ListTokensToMigrateParams

type ListTokensToMigrateParams struct {
	DefaultAlgorithm  string `json:"default_algorithm"`
	DefaultKeyVersion string `json:"default_key_version"`
	BatchOffset       int64  `json:"batch_offset"`
	BatchSize         int64  `json:"batch_size"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type LockIfThresholdNotExceededParams

type LockIfThresholdNotExceededParams struct {
	Entity           Entities  `json:"entity"`
	ProjectID        uuid.UUID `json:"project_id"`
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
	Interval         string    `json:"interval"`
}

type NullActionType

type NullActionType struct {
	ActionType ActionType `json:"action_type"`
	Valid      bool       `json:"valid"` // Valid is true if ActionType is not NULL
}

func ValidateAlertType

func ValidateAlertType(r string) NullActionType

ValidateAlertType validates the alert type, defaulting to "on" if invalid

func ValidateRemediateType

func ValidateRemediateType(r string) NullActionType

ValidateRemediateType validates the remediate type, defaulting to "off" if invalid

func (*NullActionType) Scan

func (ns *NullActionType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullActionType) Value

func (ns NullActionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullAlertStatusTypes

type NullAlertStatusTypes struct {
	AlertStatusTypes AlertStatusTypes `json:"alert_status_types"`
	Valid            bool             `json:"valid"` // Valid is true if AlertStatusTypes is not NULL
}

func (*NullAlertStatusTypes) Scan

func (ns *NullAlertStatusTypes) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAlertStatusTypes) Value

func (ns NullAlertStatusTypes) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullAuthorizationFlow

type NullAuthorizationFlow struct {
	AuthorizationFlow AuthorizationFlow `json:"authorization_flow"`
	Valid             bool              `json:"valid"` // Valid is true if AuthorizationFlow is not NULL
}

func (*NullAuthorizationFlow) Scan

func (ns *NullAuthorizationFlow) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAuthorizationFlow) Value

func (ns NullAuthorizationFlow) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullEntities

type NullEntities struct {
	Entities Entities `json:"entities"`
	Valid    bool     `json:"valid"` // Valid is true if Entities is not NULL
}

func (*NullEntities) Scan

func (ns *NullEntities) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullEntities) Value

func (ns NullEntities) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullEvalStatusTypes

type NullEvalStatusTypes struct {
	EvalStatusTypes EvalStatusTypes `json:"eval_status_types"`
	Valid           bool            `json:"valid"` // Valid is true if EvalStatusTypes is not NULL
}

func (*NullEvalStatusTypes) Scan

func (ns *NullEvalStatusTypes) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullEvalStatusTypes) Value

func (ns NullEvalStatusTypes) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullProviderClass

type NullProviderClass struct {
	ProviderClass ProviderClass `json:"provider_class"`
	Valid         bool          `json:"valid"` // Valid is true if ProviderClass is not NULL
}

func (*NullProviderClass) Scan

func (ns *NullProviderClass) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullProviderClass) Value

func (ns NullProviderClass) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullProviderType

type NullProviderType struct {
	ProviderType ProviderType `json:"provider_type"`
	Valid        bool         `json:"valid"` // Valid is true if ProviderType is not NULL
}

func (*NullProviderType) Scan

func (ns *NullProviderType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullProviderType) Value

func (ns NullProviderType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullReleaseStatus

type NullReleaseStatus struct {
	ReleaseStatus ReleaseStatus `json:"release_status"`
	Valid         bool          `json:"valid"` // Valid is true if ReleaseStatus is not NULL
}

func (*NullReleaseStatus) Scan

func (ns *NullReleaseStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullReleaseStatus) Value

func (ns NullReleaseStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullRemediationStatusTypes

type NullRemediationStatusTypes struct {
	RemediationStatusTypes RemediationStatusTypes `json:"remediation_status_types"`
	Valid                  bool                   `json:"valid"` // Valid is true if RemediationStatusTypes is not NULL
}

func (*NullRemediationStatusTypes) Scan

func (ns *NullRemediationStatusTypes) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullRemediationStatusTypes) Value

Value implements the driver Valuer interface.

type NullSeverity

type NullSeverity struct {
	Severity Severity `json:"severity"`
	Valid    bool     `json:"valid"` // Valid is true if Severity is not NULL
}

func (*NullSeverity) Scan

func (ns *NullSeverity) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullSeverity) Value

func (ns NullSeverity) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type OrphanProjectParams

type OrphanProjectParams struct {
	ID       uuid.UUID       `json:"id"`
	Metadata json.RawMessage `json:"metadata"`
}

type PgTime

type PgTime struct{ time.Time }

PgTime wraps a time.Time

func (*PgTime) Scan

func (t *PgTime) Scan(val interface{}) error

Scan implements the sql.Scanner interface

func (*PgTime) Value

func (t *PgTime) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type PgTimeArray

type PgTimeArray []PgTime

PgTimeArray wraps a time.Time slice to be used as a Postgres array type PgTimeArray []time.Time

func (*PgTimeArray) Scan

func (a *PgTimeArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (*PgTimeArray) Value

func (a *PgTimeArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type Profile

type Profile struct {
	ID             uuid.UUID      `json:"id"`
	Name           string         `json:"name"`
	Provider       sql.NullString `json:"provider"`
	ProjectID      uuid.UUID      `json:"project_id"`
	Remediate      NullActionType `json:"remediate"`
	Alert          NullActionType `json:"alert"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	ProviderID     uuid.NullUUID  `json:"provider_id"`
	SubscriptionID uuid.NullUUID  `json:"subscription_id"`
	DisplayName    string         `json:"display_name"`
	Labels         []string       `json:"labels"`
}

type ProfileRow

type ProfileRow interface {
	GetProfile() Profile
	GetEntityProfile() NullEntities
	GetSelectors() []ProfileSelector
	GetContextualRules() pqtype.NullRawMessage
}

ProfileRow is an interface row in the profiles table

type ProfileSelector

type ProfileSelector struct {
	ID        uuid.UUID    `json:"id"`
	ProfileID uuid.UUID    `json:"profile_id"`
	Entity    NullEntities `json:"entity"`
	Selector  string       `json:"selector"`
	Comment   string       `json:"comment"`
}

func (*ProfileSelector) Scan

func (s *ProfileSelector) Scan(value interface{}) error

Scan implements the sql.Scanner interface for the SelectorInfo struct

type ProfileStatus

type ProfileStatus struct {
	ID            uuid.UUID       `json:"id"`
	ProfileID     uuid.UUID       `json:"profile_id"`
	ProfileStatus EvalStatusTypes `json:"profile_status"`
	LastUpdated   time.Time       `json:"last_updated"`
}

type ProfilesWithEntityProfile

type ProfilesWithEntityProfile struct {
	ID              uuid.NullUUID         `json:"id"`
	Entity          NullEntities          `json:"entity"`
	ProfileID       uuid.NullUUID         `json:"profile_id"`
	ContextualRules pqtype.NullRawMessage `json:"contextual_rules"`
	CreatedAt       sql.NullTime          `json:"created_at"`
	UpdatedAt       sql.NullTime          `json:"updated_at"`
	Profid          uuid.UUID             `json:"profid"`
}

type Project

type Project struct {
	ID             uuid.UUID       `json:"id"`
	Name           string          `json:"name"`
	IsOrganization bool            `json:"is_organization"`
	Metadata       json.RawMessage `json:"metadata"`
	ParentID       uuid.NullUUID   `json:"parent_id"`
	CreatedAt      time.Time       `json:"created_at"`
	UpdatedAt      time.Time       `json:"updated_at"`
}

type Property

type Property struct {
	ID        uuid.UUID       `json:"id"`
	EntityID  uuid.UUID       `json:"entity_id"`
	Key       string          `json:"key"`
	Value     json.RawMessage `json:"value"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type PropertyValueV1

type PropertyValueV1 struct {
	ID        uuid.UUID `json:"id"`
	EntityID  uuid.UUID `json:"entity_id"`
	Key       string    `json:"key"`
	Value     any       `json:"value"`
	UpdatedAt time.Time `json:"updated_at"`
}

PropertyValueV1 is a property value for an entity

type PropertyWrapper

type PropertyWrapper struct {
	Version string `json:"version"`
	Value   any    `json:"value"`
}

PropertyWrapper is a wrapper around a property value that includes a version to serialize as JSON

type Provider

type Provider struct {
	ID         uuid.UUID           `json:"id"`
	Name       string              `json:"name"`
	Version    string              `json:"version"`
	ProjectID  uuid.UUID           `json:"project_id"`
	Implements []ProviderType      `json:"implements"`
	Definition json.RawMessage     `json:"definition"`
	CreatedAt  time.Time           `json:"created_at"`
	UpdatedAt  time.Time           `json:"updated_at"`
	AuthFlows  []AuthorizationFlow `json:"auth_flows"`
	Class      ProviderClass       `json:"class"`
}

func (*Provider) CanImplement

func (p *Provider) CanImplement(impl ProviderType) bool

CanImplement returns true if the provider implements the given type.

type ProviderAccessToken

type ProviderAccessToken struct {
	ID                   int32                 `json:"id"`
	Provider             string                `json:"provider"`
	ProjectID            uuid.UUID             `json:"project_id"`
	OwnerFilter          sql.NullString        `json:"owner_filter"`
	EncryptedToken       sql.NullString        `json:"encrypted_token"`
	ExpirationTime       time.Time             `json:"expiration_time"`
	CreatedAt            time.Time             `json:"created_at"`
	UpdatedAt            time.Time             `json:"updated_at"`
	EnrollmentNonce      sql.NullString        `json:"enrollment_nonce"`
	EncryptedAccessToken pqtype.NullRawMessage `json:"encrypted_access_token"`
}

type ProviderClass

type ProviderClass string
const (
	ProviderClassGithub    ProviderClass = "github"
	ProviderClassGithubApp ProviderClass = "github-app"
	ProviderClassGhcr      ProviderClass = "ghcr"
	ProviderClassDockerhub ProviderClass = "dockerhub"
	ProviderClassGitlab    ProviderClass = "gitlab"
)

func (*ProviderClass) Scan

func (e *ProviderClass) Scan(src interface{}) error

type ProviderGithubAppInstallation

type ProviderGithubAppInstallation struct {
	AppInstallationID int64          `json:"app_installation_id"`
	ProviderID        uuid.NullUUID  `json:"provider_id"`
	OrganizationID    int64          `json:"organization_id"`
	EnrollingUserID   sql.NullString `json:"enrolling_user_id"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
	EnrollmentNonce   sql.NullString `json:"enrollment_nonce"`
	ProjectID         uuid.NullUUID  `json:"project_id"`
	IsOrg             bool           `json:"is_org"`
}

type ProviderType

type ProviderType string
const (
	ProviderTypeGithub      ProviderType = "github"
	ProviderTypeRest        ProviderType = "rest"
	ProviderTypeGit         ProviderType = "git"
	ProviderTypeOci         ProviderType = "oci"
	ProviderTypeRepoLister  ProviderType = "repo-lister"
	ProviderTypeImageLister ProviderType = "image-lister"
)

func (*ProviderType) Scan

func (e *ProviderType) Scan(src interface{}) error

type PullRequest

type PullRequest struct {
	ID           uuid.UUID `json:"id"`
	RepositoryID uuid.UUID `json:"repository_id"`
	PrNumber     int64     `json:"pr_number"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type Querier

type Querier interface {
	BulkGetProfilesByID(ctx context.Context, profileIds []uuid.UUID) ([]BulkGetProfilesByIDRow, error)
	CountProfilesByEntityType(ctx context.Context) ([]CountProfilesByEntityTypeRow, error)
	CountProfilesByName(ctx context.Context, name string) (int64, error)
	CountProfilesByProjectID(ctx context.Context, projectID uuid.UUID) (int64, error)
	CountRepositories(ctx context.Context) (int64, error)
	CountRepositoriesByProjectID(ctx context.Context, projectID uuid.UUID) (int64, error)
	CountUsers(ctx context.Context) (int64, error)
	// CreateEntity adds an entry to the entity_instances table so it can be tracked by Minder.
	CreateEntity(ctx context.Context, arg CreateEntityParams) (EntityInstance, error)
	// CreateEntityWithID adds an entry to the entities table with a specific ID so it can be tracked by Minder.
	CreateEntityWithID(ctx context.Context, arg CreateEntityWithIDParams) (EntityInstance, error)
	// CreateInvitation creates a new invitation. The code is a secret that is sent
	// to the invitee, and the email is the address to which the invitation will be
	// sent. The role is the role that the invitee will have when they accept the
	// invitation. The project is the project to which the invitee will be invited.
	// The sponsor is the user who is inviting the invitee.
	CreateInvitation(ctx context.Context, arg CreateInvitationParams) (UserInvite, error)
	// CreateOrEnsureEntityByID adds an entry to the entity_instances table if it does not exist, or returns the existing entry.
	CreateOrEnsureEntityByID(ctx context.Context, arg CreateOrEnsureEntityByIDParams) (EntityInstance, error)
	CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error)
	CreateProfileForEntity(ctx context.Context, arg CreateProfileForEntityParams) (EntityProfile, error)
	CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)
	CreateProjectWithID(ctx context.Context, arg CreateProjectWithIDParams) (Project, error)
	CreateProvider(ctx context.Context, arg CreateProviderParams) (Provider, error)
	CreateRepository(ctx context.Context, arg CreateRepositoryParams) (Repository, error)
	CreateRuleType(ctx context.Context, arg CreateRuleTypeParams) (RuleType, error)
	CreateSelector(ctx context.Context, arg CreateSelectorParams) (ProfileSelector, error)
	CreateSessionState(ctx context.Context, arg CreateSessionStateParams) (SessionStore, error)
	// Subscriptions --
	CreateSubscription(ctx context.Context, arg CreateSubscriptionParams) (Subscription, error)
	CreateUser(ctx context.Context, identitySubject string) (User, error)
	DeleteAllPropertiesForEntity(ctx context.Context, entityID uuid.UUID) error
	DeleteArtifact(ctx context.Context, id uuid.UUID) error
	// DeleteEntity removes an entity from the entity_instances table for a project.
	DeleteEntity(ctx context.Context, arg DeleteEntityParams) error
	DeleteEvaluationHistoryByIDs(ctx context.Context, evaluationids []uuid.UUID) (int64, error)
	DeleteExpiredSessionStates(ctx context.Context) (int64, error)
	DeleteInstallationIDByAppID(ctx context.Context, appInstallationID int64) error
	// DeleteInvitation deletes an invitation by its code. This is intended to be
	// called by a user who has issued an invitation and then accepted it, declined
	// it or the sponsor has decided to revoke it.
	DeleteInvitation(ctx context.Context, code string) (UserInvite, error)
	DeleteNonUpdatedRules(ctx context.Context, arg DeleteNonUpdatedRulesParams) error
	DeleteProfile(ctx context.Context, arg DeleteProfileParams) error
	DeleteProfileForEntity(ctx context.Context, arg DeleteProfileForEntityParams) error
	DeleteProject(ctx context.Context, id uuid.UUID) ([]DeleteProjectRow, error)
	DeleteProperty(ctx context.Context, arg DeletePropertyParams) error
	DeleteProvider(ctx context.Context, arg DeleteProviderParams) error
	DeleteRepository(ctx context.Context, id uuid.UUID) error
	DeleteRuleType(ctx context.Context, id uuid.UUID) error
	DeleteSelector(ctx context.Context, id uuid.UUID) error
	DeleteSelectorsByProfileID(ctx context.Context, profileID uuid.UUID) error
	DeleteSessionStateByProjectID(ctx context.Context, arg DeleteSessionStateByProjectIDParams) error
	DeleteUser(ctx context.Context, id int32) error
	EnqueueFlush(ctx context.Context, arg EnqueueFlushParams) (FlushCache, error)
	// FindProviders allows us to take a trait and filter
	// providers by it. It also optionally takes a name, in case we want to
	// filter by name as well.
	FindProviders(ctx context.Context, arg FindProvidersParams) ([]Provider, error)
	FlushCache(ctx context.Context, entityInstanceID uuid.UUID) (FlushCache, error)
	GetAccessTokenByEnrollmentNonce(ctx context.Context, arg GetAccessTokenByEnrollmentNonceParams) (ProviderAccessToken, error)
	GetAccessTokenByProjectID(ctx context.Context, arg GetAccessTokenByProjectIDParams) (ProviderAccessToken, error)
	GetAccessTokenByProvider(ctx context.Context, provider string) ([]ProviderAccessToken, error)
	GetAccessTokenSinceDate(ctx context.Context, arg GetAccessTokenSinceDateParams) (ProviderAccessToken, error)
	GetAllPropertiesForEntity(ctx context.Context, entityID uuid.UUID) ([]Property, error)
	GetArtifactByID(ctx context.Context, arg GetArtifactByIDParams) (Artifact, error)
	GetArtifactByName(ctx context.Context, arg GetArtifactByNameParams) (Artifact, error)
	GetBundle(ctx context.Context, arg GetBundleParams) (Bundle, error)
	GetChildrenProjects(ctx context.Context, id uuid.UUID) ([]GetChildrenProjectsRow, error)
	// GetEntitiesByProjectHierarchy retrieves all entities for a project or hierarchy of projects.
	GetEntitiesByProjectHierarchy(ctx context.Context, projects []uuid.UUID) ([]EntityInstance, error)
	// GetEntitiesByProvider retrieves all entities of a given provider.
	// this is how one would get all repositories, artifacts, etc. for a given provider.
	GetEntitiesByProvider(ctx context.Context, providerID uuid.UUID) ([]EntityInstance, error)
	// GetEntitiesByType retrieves all entities of a given type for a project or hierarchy of projects.
	// this is how one would get all repositories, artifacts, etc.
	GetEntitiesByType(ctx context.Context, arg GetEntitiesByTypeParams) ([]EntityInstance, error)
	GetEntitlementFeaturesByProjectID(ctx context.Context, projectID uuid.UUID) ([]string, error)
	// GetEntityByID retrieves an entity by its ID for a project or hierarchy of projects.
	GetEntityByID(ctx context.Context, id uuid.UUID) (EntityInstance, error)
	// GetEntityByName retrieves an entity by its name for a project or hierarchy of projects.
	GetEntityByName(ctx context.Context, arg GetEntityByNameParams) (EntityInstance, error)
	GetEvaluationHistory(ctx context.Context, arg GetEvaluationHistoryParams) (GetEvaluationHistoryRow, error)
	// GetFeatureInProject verifies if a feature is available for a specific project.
	// It returns the settings for the feature if it is available.
	GetFeatureInProject(ctx context.Context, arg GetFeatureInProjectParams) (json.RawMessage, error)
	// GetImmediateChildrenProjects is a query that returns all the immediate children of a project.
	GetImmediateChildrenProjects(ctx context.Context, parentID uuid.UUID) ([]Project, error)
	GetInstallationIDByAppID(ctx context.Context, appInstallationID int64) (ProviderGithubAppInstallation, error)
	GetInstallationIDByEnrollmentNonce(ctx context.Context, arg GetInstallationIDByEnrollmentNonceParams) (ProviderGithubAppInstallation, error)
	GetInstallationIDByProviderID(ctx context.Context, providerID uuid.NullUUID) (ProviderGithubAppInstallation, error)
	// GetInvitationByCode retrieves an invitation by its code. This is intended to
	// be called by a user who has received an invitation email and is following the
	// link to accept the invitation or when querying for additional info about the
	// invitation.
	GetInvitationByCode(ctx context.Context, code string) (GetInvitationByCodeRow, error)
	// GetInvitationsByEmail retrieves all invitations for a given email address.
	// This is intended to be called by a logged in user with their own email address,
	// to allow them to accept invitations even if email delivery was not working.
	// Note that this requires that the destination email address matches the email
	// address of the logged in user in the external identity service / auth token.
	// This clarification is related solely for user's ListInvitations calls and does
	// not affect to resolving invitations intended for other mail addresses.
	GetInvitationsByEmail(ctx context.Context, email string) ([]GetInvitationsByEmailRow, error)
	// GetInvitationsByEmailAndProject retrieves all invitations by email and project.
	GetInvitationsByEmailAndProject(ctx context.Context, arg GetInvitationsByEmailAndProjectParams) ([]GetInvitationsByEmailAndProjectRow, error)
	// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
	// SPDX-License-Identifier: Apache-2.0
	GetLatestEvalStateForRuleEntity(ctx context.Context, arg GetLatestEvalStateForRuleEntityParams) (EvaluationStatus, error)
	GetParentProjects(ctx context.Context, id uuid.UUID) ([]uuid.UUID, error)
	GetParentProjectsUntil(ctx context.Context, arg GetParentProjectsUntilParams) ([]uuid.UUID, error)
	GetProfileByID(ctx context.Context, arg GetProfileByIDParams) (Profile, error)
	GetProfileByIDAndLock(ctx context.Context, arg GetProfileByIDAndLockParams) (Profile, error)
	GetProfileByNameAndLock(ctx context.Context, arg GetProfileByNameAndLockParams) (Profile, error)
	GetProfileByProjectAndID(ctx context.Context, arg GetProfileByProjectAndIDParams) ([]GetProfileByProjectAndIDRow, error)
	GetProfileByProjectAndName(ctx context.Context, arg GetProfileByProjectAndNameParams) ([]GetProfileByProjectAndNameRow, error)
	GetProfileStatusByIdAndProject(ctx context.Context, arg GetProfileStatusByIdAndProjectParams) (GetProfileStatusByIdAndProjectRow, error)
	GetProfileStatusByNameAndProject(ctx context.Context, arg GetProfileStatusByNameAndProjectParams) (GetProfileStatusByNameAndProjectRow, error)
	GetProfileStatusByProject(ctx context.Context, projectID uuid.UUID) ([]GetProfileStatusByProjectRow, error)
	GetProjectByID(ctx context.Context, id uuid.UUID) (Project, error)
	GetProjectByName(ctx context.Context, name string) (Project, error)
	GetProjectIDBySessionState(ctx context.Context, sessionState string) (GetProjectIDBySessionStateRow, error)
	GetProperty(ctx context.Context, arg GetPropertyParams) (Property, error)
	GetProviderByID(ctx context.Context, id uuid.UUID) (Provider, error)
	GetProviderByIDAndProject(ctx context.Context, arg GetProviderByIDAndProjectParams) (Provider, error)
	// GetProviderByName allows us to get a provider by its name. This takes
	// into account the project hierarchy, so it will only return the provider
	// if it exists in the project or any of its ancestors. It'll return the first
	// provider that matches the name.
	GetProviderByName(ctx context.Context, arg GetProviderByNameParams) (Provider, error)
	// avoid using this, where possible use GetRepositoryByIDAndProject instead
	GetRepositoryByID(ctx context.Context, id uuid.UUID) (Repository, error)
	GetRepositoryByIDAndProject(ctx context.Context, arg GetRepositoryByIDAndProjectParams) (Repository, error)
	GetRepositoryByRepoID(ctx context.Context, repoID int64) (Repository, error)
	GetRepositoryByRepoName(ctx context.Context, arg GetRepositoryByRepoNameParams) (Repository, error)
	GetRuleInstancesEntityInProjects(ctx context.Context, arg GetRuleInstancesEntityInProjectsParams) ([]RuleInstance, error)
	GetRuleInstancesForProfile(ctx context.Context, profileID uuid.UUID) ([]RuleInstance, error)
	GetRuleTypeByID(ctx context.Context, id uuid.UUID) (RuleType, error)
	GetRuleTypeByName(ctx context.Context, arg GetRuleTypeByNameParams) (RuleType, error)
	// intended as a temporary transition query
	// this will be removed once rule_instances is used consistently in the engine
	GetRuleTypeIDByRuleNameEntityProfile(ctx context.Context, arg GetRuleTypeIDByRuleNameEntityProfileParams) (uuid.UUID, error)
	// intended as a temporary transition query
	// this will be removed once the evaluation history tables replace the old state tables
	GetRuleTypeNameByID(ctx context.Context, id uuid.UUID) (string, error)
	GetRuleTypesByEntityInHierarchy(ctx context.Context, arg GetRuleTypesByEntityInHierarchyParams) ([]RuleType, error)
	GetSelectorByID(ctx context.Context, id uuid.UUID) (ProfileSelector, error)
	GetSelectorsByProfileID(ctx context.Context, profileID uuid.UUID) ([]ProfileSelector, error)
	GetSubscriptionByProjectBundle(ctx context.Context, arg GetSubscriptionByProjectBundleParams) (Subscription, error)
	GetTypedEntitiesByProperty(ctx context.Context, arg GetTypedEntitiesByPropertyParams) ([]EntityInstance, error)
	GetUnclaimedInstallationsByUser(ctx context.Context, ghID sql.NullString) ([]ProviderGithubAppInstallation, error)
	GetUserByID(ctx context.Context, id int32) (User, error)
	GetUserBySubject(ctx context.Context, identitySubject string) (User, error)
	GlobalListProviders(ctx context.Context) ([]Provider, error)
	GlobalListProvidersByClass(ctx context.Context, class ProviderClass) ([]Provider, error)
	InsertAlertEvent(ctx context.Context, arg InsertAlertEventParams) error
	InsertEvaluationRuleEntity(ctx context.Context, arg InsertEvaluationRuleEntityParams) (uuid.UUID, error)
	InsertEvaluationStatus(ctx context.Context, arg InsertEvaluationStatusParams) (uuid.UUID, error)
	InsertRemediationEvent(ctx context.Context, arg InsertRemediationEventParams) error
	ListArtifactsByRepoID(ctx context.Context, repositoryID uuid.NullUUID) ([]Artifact, error)
	ListEvaluationHistory(ctx context.Context, arg ListEvaluationHistoryParams) ([]ListEvaluationHistoryRow, error)
	ListEvaluationHistoryStaleRecords(ctx context.Context, arg ListEvaluationHistoryStaleRecordsParams) ([]ListEvaluationHistoryStaleRecordsRow, error)
	ListFlushCache(ctx context.Context) ([]FlushCache, error)
	// ListInvitationsForProject collects the information visible to project
	// administrators after an invitation has been issued.  In particular, it
	// *does not* report the invitation code, which is a secret intended for
	// the invitee.
	ListInvitationsForProject(ctx context.Context, project uuid.UUID) ([]ListInvitationsForProjectRow, error)
	// ListOldestRuleEvaluationsByRepositoryId has casts in select statement as sqlc generates incorrect types.
	// cast after MIN is required due to a known bug in sqlc: https://github.com/sqlc-dev/sqlc/issues/1965
	ListOldestRuleEvaluationsByRepositoryId(ctx context.Context, repositoryIds []uuid.UUID) ([]ListOldestRuleEvaluationsByRepositoryIdRow, error)
	ListProfilesByProjectIDAndLabel(ctx context.Context, arg ListProfilesByProjectIDAndLabelParams) ([]ListProfilesByProjectIDAndLabelRow, error)
	ListProfilesInstantiatingRuleType(ctx context.Context, ruleTypeID uuid.UUID) ([]string, error)
	// ListProvidersByProjectID allows us to list all providers
	// for a given array of projects.
	ListProvidersByProjectID(ctx context.Context, projects []uuid.UUID) ([]Provider, error)
	// ListProvidersByProjectIDPaginated allows us to lits all providers for a given project
	// with pagination taken into account. In this case, the cursor is the creation date.
	ListProvidersByProjectIDPaginated(ctx context.Context, arg ListProvidersByProjectIDPaginatedParams) ([]Provider, error)
	ListRegisteredRepositoriesByProjectIDAndProvider(ctx context.Context, arg ListRegisteredRepositoriesByProjectIDAndProviderParams) ([]Repository, error)
	ListRepositoriesAfterID(ctx context.Context, arg ListRepositoriesAfterIDParams) ([]Repository, error)
	ListRepositoriesByProjectID(ctx context.Context, arg ListRepositoriesByProjectIDParams) ([]Repository, error)
	ListRuleEvaluationsByProfileId(ctx context.Context, arg ListRuleEvaluationsByProfileIdParams) ([]ListRuleEvaluationsByProfileIdRow, error)
	ListRuleTypesByProject(ctx context.Context, projectID uuid.UUID) ([]RuleType, error)
	// When doing a key/algorithm rotation, identify the secrets which need to be
	// rotated. The criteria for rotation are:
	// 1) The encrypted_access_token is NULL (this should be removed when we make
	//    this column non-nullable).
	// 2) The access token does not use the configured default algorithm.
	// 3) The access token does not use the default key version.
	// This query accepts the default key version/algorithm as arguments since
	// that information is not known to the database.
	ListTokensToMigrate(ctx context.Context, arg ListTokensToMigrateParams) ([]ProviderAccessToken, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	// LockIfThresholdNotExceeded is used to lock an entity for execution. It will
	// attempt to insert or update the entity_execution_lock table only if the
	// last_lock_time is older than the threshold. If the lock is successful, it
	// will return the lock record. If the lock is unsuccessful, it will return
	// NULL.
	LockIfThresholdNotExceeded(ctx context.Context, arg LockIfThresholdNotExceededParams) (EntityExecutionLock, error)
	// OrphanProject is a query that sets the parent_id of a project to NULL.
	OrphanProject(ctx context.Context, arg OrphanProjectParams) (Project, error)
	// ReleaseLock is used to release a lock on an entity. It will delete the
	// entity_execution_lock record if the lock is held by the given locked_by
	// value.
	ReleaseLock(ctx context.Context, arg ReleaseLockParams) error
	RepositoryExistsAfterID(ctx context.Context, id uuid.UUID) (bool, error)
	SetCurrentVersion(ctx context.Context, arg SetCurrentVersionParams) error
	UpdateEncryptedSecret(ctx context.Context, arg UpdateEncryptedSecretParams) error
	// UpdateInvitationRole updates an invitation by its code. This is intended to be
	// called by a user who has issued an invitation and then decided to change the
	// role of the invitee.
	UpdateInvitationRole(ctx context.Context, arg UpdateInvitationRoleParams) (UserInvite, error)
	UpdateLease(ctx context.Context, arg UpdateLeaseParams) error
	UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
	UpdateProjectMeta(ctx context.Context, arg UpdateProjectMetaParams) (Project, error)
	UpdateProvider(ctx context.Context, arg UpdateProviderParams) error
	UpdateReminderLastSentForRepositories(ctx context.Context, repositoryIds []uuid.UUID) error
	UpdateRuleType(ctx context.Context, arg UpdateRuleTypeParams) (RuleType, error)
	UpdateSelector(ctx context.Context, arg UpdateSelectorParams) (ProfileSelector, error)
	UpsertAccessToken(ctx context.Context, arg UpsertAccessTokenParams) (ProviderAccessToken, error)
	UpsertArtifact(ctx context.Context, arg UpsertArtifactParams) (Artifact, error)
	// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
	// SPDX-License-Identifier: Apache-2.0
	// Bundles --
	UpsertBundle(ctx context.Context, arg UpsertBundleParams) error
	UpsertInstallationID(ctx context.Context, arg UpsertInstallationIDParams) (ProviderGithubAppInstallation, error)
	UpsertLatestEvaluationStatus(ctx context.Context, arg UpsertLatestEvaluationStatusParams) error
	UpsertProfileForEntity(ctx context.Context, arg UpsertProfileForEntityParams) (EntityProfile, error)
	UpsertProperty(ctx context.Context, arg UpsertPropertyParams) (Property, error)
	// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
	// SPDX-License-Identifier: Apache-2.0
	UpsertRuleInstance(ctx context.Context, arg UpsertRuleInstanceParams) (uuid.UUID, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) BulkGetProfilesByID

func (q *Queries) BulkGetProfilesByID(ctx context.Context, profileIds []uuid.UUID) ([]BulkGetProfilesByIDRow, error)

func (*Queries) CountProfilesByEntityType

func (q *Queries) CountProfilesByEntityType(ctx context.Context) ([]CountProfilesByEntityTypeRow, error)

func (*Queries) CountProfilesByName

func (q *Queries) CountProfilesByName(ctx context.Context, name string) (int64, error)

func (*Queries) CountProfilesByProjectID

func (q *Queries) CountProfilesByProjectID(ctx context.Context, projectID uuid.UUID) (int64, error)

func (*Queries) CountRepositories

func (q *Queries) CountRepositories(ctx context.Context) (int64, error)

func (*Queries) CountRepositoriesByProjectID

func (q *Queries) CountRepositoriesByProjectID(ctx context.Context, projectID uuid.UUID) (int64, error)

func (*Queries) CountUsers

func (q *Queries) CountUsers(ctx context.Context) (int64, error)

func (*Queries) CreateEntity

func (q *Queries) CreateEntity(ctx context.Context, arg CreateEntityParams) (EntityInstance, error)

CreateEntity adds an entry to the entity_instances table so it can be tracked by Minder.

func (*Queries) CreateEntityWithID

func (q *Queries) CreateEntityWithID(ctx context.Context, arg CreateEntityWithIDParams) (EntityInstance, error)

CreateEntityWithID adds an entry to the entities table with a specific ID so it can be tracked by Minder.

func (*Queries) CreateInvitation

func (q *Queries) CreateInvitation(ctx context.Context, arg CreateInvitationParams) (UserInvite, error)

CreateInvitation creates a new invitation. The code is a secret that is sent to the invitee, and the email is the address to which the invitation will be sent. The role is the role that the invitee will have when they accept the invitation. The project is the project to which the invitee will be invited. The sponsor is the user who is inviting the invitee.

func (*Queries) CreateOrEnsureEntityByID

func (q *Queries) CreateOrEnsureEntityByID(ctx context.Context, arg CreateOrEnsureEntityByIDParams) (EntityInstance, error)

CreateOrEnsureEntityByID adds an entry to the entity_instances table if it does not exist, or returns the existing entry.

func (*Queries) CreateOrganization

func (q *Queries) CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Project, error)

func (*Queries) CreateProfile

func (q *Queries) CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error)

func (*Queries) CreateProfileForEntity

func (q *Queries) CreateProfileForEntity(ctx context.Context, arg CreateProfileForEntityParams) (EntityProfile, error)

func (*Queries) CreateProject

func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)

func (*Queries) CreateProjectWithID

func (q *Queries) CreateProjectWithID(ctx context.Context, arg CreateProjectWithIDParams) (Project, error)

func (*Queries) CreateProvider

func (q *Queries) CreateProvider(ctx context.Context, arg CreateProviderParams) (Provider, error)

func (*Queries) CreateRepository

func (q *Queries) CreateRepository(ctx context.Context, arg CreateRepositoryParams) (Repository, error)

func (*Queries) CreateRuleType

func (q *Queries) CreateRuleType(ctx context.Context, arg CreateRuleTypeParams) (RuleType, error)

func (*Queries) CreateSelector

func (q *Queries) CreateSelector(ctx context.Context, arg CreateSelectorParams) (ProfileSelector, error)

func (*Queries) CreateSessionState

func (q *Queries) CreateSessionState(ctx context.Context, arg CreateSessionStateParams) (SessionStore, error)

func (*Queries) CreateSubscription

func (q *Queries) CreateSubscription(ctx context.Context, arg CreateSubscriptionParams) (Subscription, error)

Subscriptions --

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, identitySubject string) (User, error)

func (*Queries) DeleteAllPropertiesForEntity

func (q *Queries) DeleteAllPropertiesForEntity(ctx context.Context, entityID uuid.UUID) error

func (*Queries) DeleteArtifact

func (q *Queries) DeleteArtifact(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteEntity

func (q *Queries) DeleteEntity(ctx context.Context, arg DeleteEntityParams) error

DeleteEntity removes an entity from the entity_instances table for a project.

func (*Queries) DeleteEvaluationHistoryByIDs

func (q *Queries) DeleteEvaluationHistoryByIDs(ctx context.Context, evaluationids []uuid.UUID) (int64, error)

func (*Queries) DeleteExpiredSessionStates

func (q *Queries) DeleteExpiredSessionStates(ctx context.Context) (int64, error)

func (*Queries) DeleteInstallationIDByAppID

func (q *Queries) DeleteInstallationIDByAppID(ctx context.Context, appInstallationID int64) error

func (*Queries) DeleteInvitation

func (q *Queries) DeleteInvitation(ctx context.Context, code string) (UserInvite, error)

DeleteInvitation deletes an invitation by its code. This is intended to be called by a user who has issued an invitation and then accepted it, declined it or the sponsor has decided to revoke it.

func (*Queries) DeleteNonUpdatedRules

func (q *Queries) DeleteNonUpdatedRules(ctx context.Context, arg DeleteNonUpdatedRulesParams) error

func (*Queries) DeleteOrganization

func (q *Queries) DeleteOrganization(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteProfile

func (q *Queries) DeleteProfile(ctx context.Context, arg DeleteProfileParams) error

func (*Queries) DeleteProfileForEntity

func (q *Queries) DeleteProfileForEntity(ctx context.Context, arg DeleteProfileForEntityParams) error

func (*Queries) DeleteProject

func (q *Queries) DeleteProject(ctx context.Context, id uuid.UUID) ([]DeleteProjectRow, error)

func (*Queries) DeleteProperty

func (q *Queries) DeleteProperty(ctx context.Context, arg DeletePropertyParams) error

func (*Queries) DeleteProvider

func (q *Queries) DeleteProvider(ctx context.Context, arg DeleteProviderParams) error

func (*Queries) DeleteRepository

func (q *Queries) DeleteRepository(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteRuleType

func (q *Queries) DeleteRuleType(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteSelector

func (q *Queries) DeleteSelector(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteSelectorsByProfileID

func (q *Queries) DeleteSelectorsByProfileID(ctx context.Context, profileID uuid.UUID) error

func (*Queries) DeleteSessionStateByProjectID

func (q *Queries) DeleteSessionStateByProjectID(ctx context.Context, arg DeleteSessionStateByProjectIDParams) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int32) error

func (*Queries) EnqueueFlush

func (q *Queries) EnqueueFlush(ctx context.Context, arg EnqueueFlushParams) (FlushCache, error)

func (*Queries) FindProviders

func (q *Queries) FindProviders(ctx context.Context, arg FindProvidersParams) ([]Provider, error)

FindProviders allows us to take a trait and filter providers by it. It also optionally takes a name, in case we want to filter by name as well.

func (*Queries) FlushCache

func (q *Queries) FlushCache(ctx context.Context, entityInstanceID uuid.UUID) (FlushCache, error)

func (*Queries) GetAccessTokenByEnrollmentNonce

func (q *Queries) GetAccessTokenByEnrollmentNonce(ctx context.Context, arg GetAccessTokenByEnrollmentNonceParams) (ProviderAccessToken, error)

func (*Queries) GetAccessTokenByProjectID

func (q *Queries) GetAccessTokenByProjectID(ctx context.Context, arg GetAccessTokenByProjectIDParams) (ProviderAccessToken, error)

func (*Queries) GetAccessTokenByProvider

func (q *Queries) GetAccessTokenByProvider(ctx context.Context, provider string) ([]ProviderAccessToken, error)

func (*Queries) GetAccessTokenSinceDate

func (q *Queries) GetAccessTokenSinceDate(ctx context.Context, arg GetAccessTokenSinceDateParams) (ProviderAccessToken, error)

func (*Queries) GetAllPropertiesForEntity

func (q *Queries) GetAllPropertiesForEntity(ctx context.Context, entityID uuid.UUID) ([]Property, error)

func (*Queries) GetAllPropertyValuesV1

func (q *Queries) GetAllPropertyValuesV1(ctx context.Context, entityID uuid.UUID) ([]PropertyValueV1, error)

GetAllPropertyValuesV1 retrieves all property values for an entity

func (*Queries) GetArtifactByID

func (q *Queries) GetArtifactByID(ctx context.Context, arg GetArtifactByIDParams) (Artifact, error)

func (*Queries) GetArtifactByName

func (q *Queries) GetArtifactByName(ctx context.Context, arg GetArtifactByNameParams) (Artifact, error)

func (*Queries) GetBundle

func (q *Queries) GetBundle(ctx context.Context, arg GetBundleParams) (Bundle, error)

func (*Queries) GetChildrenProjects

func (q *Queries) GetChildrenProjects(ctx context.Context, id uuid.UUID) ([]GetChildrenProjectsRow, error)

func (*Queries) GetEntitiesByProjectHierarchy

func (q *Queries) GetEntitiesByProjectHierarchy(ctx context.Context, projects []uuid.UUID) ([]EntityInstance, error)

GetEntitiesByProjectHierarchy retrieves all entities for a project or hierarchy of projects.

func (*Queries) GetEntitiesByProvider

func (q *Queries) GetEntitiesByProvider(ctx context.Context, providerID uuid.UUID) ([]EntityInstance, error)

GetEntitiesByProvider retrieves all entities of a given provider. this is how one would get all repositories, artifacts, etc. for a given provider.

func (*Queries) GetEntitiesByType

func (q *Queries) GetEntitiesByType(ctx context.Context, arg GetEntitiesByTypeParams) ([]EntityInstance, error)

GetEntitiesByType retrieves all entities of a given type for a project or hierarchy of projects. this is how one would get all repositories, artifacts, etc.

func (*Queries) GetEntitlementFeaturesByProjectID

func (q *Queries) GetEntitlementFeaturesByProjectID(ctx context.Context, projectID uuid.UUID) ([]string, error)

func (*Queries) GetEntityByID

func (q *Queries) GetEntityByID(ctx context.Context, id uuid.UUID) (EntityInstance, error)

GetEntityByID retrieves an entity by its ID for a project or hierarchy of projects.

func (*Queries) GetEntityByName

func (q *Queries) GetEntityByName(ctx context.Context, arg GetEntityByNameParams) (EntityInstance, error)

GetEntityByName retrieves an entity by its name for a project or hierarchy of projects.

func (*Queries) GetEvaluationHistory

func (q *Queries) GetEvaluationHistory(ctx context.Context, arg GetEvaluationHistoryParams) (GetEvaluationHistoryRow, error)

func (*Queries) GetFeatureInProject

func (q *Queries) GetFeatureInProject(ctx context.Context, arg GetFeatureInProjectParams) (json.RawMessage, error)

GetFeatureInProject verifies if a feature is available for a specific project. It returns the settings for the feature if it is available.

func (*Queries) GetImmediateChildrenProjects

func (q *Queries) GetImmediateChildrenProjects(ctx context.Context, parentID uuid.UUID) ([]Project, error)

GetImmediateChildrenProjects is a query that returns all the immediate children of a project.

func (*Queries) GetInstallationIDByAppID

func (q *Queries) GetInstallationIDByAppID(ctx context.Context, appInstallationID int64) (ProviderGithubAppInstallation, error)

func (*Queries) GetInstallationIDByProviderID

func (q *Queries) GetInstallationIDByProviderID(ctx context.Context, providerID uuid.NullUUID) (ProviderGithubAppInstallation, error)

func (*Queries) GetInvitationByCode

func (q *Queries) GetInvitationByCode(ctx context.Context, code string) (GetInvitationByCodeRow, error)

GetInvitationByCode retrieves an invitation by its code. This is intended to be called by a user who has received an invitation email and is following the link to accept the invitation or when querying for additional info about the invitation.

func (*Queries) GetInvitationsByEmail

func (q *Queries) GetInvitationsByEmail(ctx context.Context, email string) ([]GetInvitationsByEmailRow, error)

GetInvitationsByEmail retrieves all invitations for a given email address. This is intended to be called by a logged in user with their own email address, to allow them to accept invitations even if email delivery was not working. Note that this requires that the destination email address matches the email address of the logged in user in the external identity service / auth token. This clarification is related solely for user's ListInvitations calls and does not affect to resolving invitations intended for other mail addresses.

func (*Queries) GetInvitationsByEmailAndProject

GetInvitationsByEmailAndProject retrieves all invitations by email and project.

func (*Queries) GetLatestEvalStateForRuleEntity

func (q *Queries) GetLatestEvalStateForRuleEntity(ctx context.Context, arg GetLatestEvalStateForRuleEntityParams) (EvaluationStatus, error)

SPDX-FileCopyrightText: Copyright 2024 The Minder Authors SPDX-License-Identifier: Apache-2.0

func (*Queries) GetOrganization

func (q *Queries) GetOrganization(ctx context.Context, id uuid.UUID) (Project, error)

func (*Queries) GetOrganizationByName

func (q *Queries) GetOrganizationByName(ctx context.Context, name string) (Project, error)

func (*Queries) GetOrganizationForUpdate

func (q *Queries) GetOrganizationForUpdate(ctx context.Context, name string) (Project, error)

func (*Queries) GetParentProjects

func (q *Queries) GetParentProjects(ctx context.Context, id uuid.UUID) ([]uuid.UUID, error)

func (*Queries) GetParentProjectsUntil

func (q *Queries) GetParentProjectsUntil(ctx context.Context, arg GetParentProjectsUntilParams) ([]uuid.UUID, error)

func (*Queries) GetProfileByID

func (q *Queries) GetProfileByID(ctx context.Context, arg GetProfileByIDParams) (Profile, error)

func (*Queries) GetProfileByIDAndLock

func (q *Queries) GetProfileByIDAndLock(ctx context.Context, arg GetProfileByIDAndLockParams) (Profile, error)

func (*Queries) GetProfileByNameAndLock

func (q *Queries) GetProfileByNameAndLock(ctx context.Context, arg GetProfileByNameAndLockParams) (Profile, error)

func (*Queries) GetProfileByProjectAndID

func (q *Queries) GetProfileByProjectAndID(ctx context.Context, arg GetProfileByProjectAndIDParams) ([]GetProfileByProjectAndIDRow, error)

func (*Queries) GetProfileByProjectAndName

func (q *Queries) GetProfileByProjectAndName(ctx context.Context, arg GetProfileByProjectAndNameParams) ([]GetProfileByProjectAndNameRow, error)

func (*Queries) GetProfileStatusByProject

func (q *Queries) GetProfileStatusByProject(ctx context.Context, projectID uuid.UUID) ([]GetProfileStatusByProjectRow, error)

func (*Queries) GetProjectByID

func (q *Queries) GetProjectByID(ctx context.Context, id uuid.UUID) (Project, error)

func (*Queries) GetProjectByName

func (q *Queries) GetProjectByName(ctx context.Context, name string) (Project, error)

func (*Queries) GetProjectIDBySessionState

func (q *Queries) GetProjectIDBySessionState(ctx context.Context, sessionState string) (GetProjectIDBySessionStateRow, error)

func (*Queries) GetProperty

func (q *Queries) GetProperty(ctx context.Context, arg GetPropertyParams) (Property, error)

func (*Queries) GetPropertyValueV1

func (q *Queries) GetPropertyValueV1(ctx context.Context, entityID uuid.UUID, key string) (PropertyValueV1, error)

GetPropertyValueV1 retrieves a property value for an entity

func (*Queries) GetProviderByID

func (q *Queries) GetProviderByID(ctx context.Context, id uuid.UUID) (Provider, error)

func (*Queries) GetProviderByIDAndProject

func (q *Queries) GetProviderByIDAndProject(ctx context.Context, arg GetProviderByIDAndProjectParams) (Provider, error)

func (*Queries) GetProviderByName

func (q *Queries) GetProviderByName(ctx context.Context, arg GetProviderByNameParams) (Provider, error)

GetProviderByName allows us to get a provider by its name. This takes into account the project hierarchy, so it will only return the provider if it exists in the project or any of its ancestors. It'll return the first provider that matches the name.

func (*Queries) GetRepositoryByID

func (q *Queries) GetRepositoryByID(ctx context.Context, id uuid.UUID) (Repository, error)

avoid using this, where possible use GetRepositoryByIDAndProject instead

func (*Queries) GetRepositoryByIDAndProject

func (q *Queries) GetRepositoryByIDAndProject(ctx context.Context, arg GetRepositoryByIDAndProjectParams) (Repository, error)

func (*Queries) GetRepositoryByRepoID

func (q *Queries) GetRepositoryByRepoID(ctx context.Context, repoID int64) (Repository, error)

func (*Queries) GetRepositoryByRepoName

func (q *Queries) GetRepositoryByRepoName(ctx context.Context, arg GetRepositoryByRepoNameParams) (Repository, error)

func (*Queries) GetRuleEvaluationByProfileIdAndRuleType

func (q *Queries) GetRuleEvaluationByProfileIdAndRuleType(
	ctx context.Context,
	profileID uuid.UUID,
	ruleName sql.NullString,
	entityID uuid.UUID,
	ruleTypeName sql.NullString,
) (*ListRuleEvaluationsByProfileIdRow, error)

GetRuleEvaluationByProfileIdAndRuleType returns the rule evaluation for a given profile and its rule name

func (*Queries) GetRuleInstancesEntityInProjects

func (q *Queries) GetRuleInstancesEntityInProjects(ctx context.Context, arg GetRuleInstancesEntityInProjectsParams) ([]RuleInstance, error)

func (*Queries) GetRuleInstancesForProfile

func (q *Queries) GetRuleInstancesForProfile(ctx context.Context, profileID uuid.UUID) ([]RuleInstance, error)

func (*Queries) GetRuleTypeByID

func (q *Queries) GetRuleTypeByID(ctx context.Context, id uuid.UUID) (RuleType, error)

func (*Queries) GetRuleTypeByName

func (q *Queries) GetRuleTypeByName(ctx context.Context, arg GetRuleTypeByNameParams) (RuleType, error)

func (*Queries) GetRuleTypeIDByRuleNameEntityProfile

func (q *Queries) GetRuleTypeIDByRuleNameEntityProfile(ctx context.Context, arg GetRuleTypeIDByRuleNameEntityProfileParams) (uuid.UUID, error)

intended as a temporary transition query this will be removed once rule_instances is used consistently in the engine

func (*Queries) GetRuleTypeNameByID

func (q *Queries) GetRuleTypeNameByID(ctx context.Context, id uuid.UUID) (string, error)

intended as a temporary transition query this will be removed once the evaluation history tables replace the old state tables

func (*Queries) GetRuleTypesByEntityInHierarchy

func (q *Queries) GetRuleTypesByEntityInHierarchy(ctx context.Context, arg GetRuleTypesByEntityInHierarchyParams) ([]RuleType, error)

func (*Queries) GetSelectorByID

func (q *Queries) GetSelectorByID(ctx context.Context, id uuid.UUID) (ProfileSelector, error)

func (*Queries) GetSelectorsByProfileID

func (q *Queries) GetSelectorsByProfileID(ctx context.Context, profileID uuid.UUID) ([]ProfileSelector, error)

func (*Queries) GetSubscriptionByProjectBundle

func (q *Queries) GetSubscriptionByProjectBundle(ctx context.Context, arg GetSubscriptionByProjectBundleParams) (Subscription, error)

func (*Queries) GetTypedEntitiesByProperty

func (q *Queries) GetTypedEntitiesByProperty(ctx context.Context, arg GetTypedEntitiesByPropertyParams) ([]EntityInstance, error)

func (*Queries) GetTypedEntitiesByPropertyV1

func (q *Queries) GetTypedEntitiesByPropertyV1(
	ctx context.Context, entType Entities, key string, value any, opts GetTypedEntitiesOptions,
) ([]EntityInstance, error)

GetTypedEntitiesByPropertyV1 retrieves all entities with a property value

func (*Queries) GetUnclaimedInstallationsByUser

func (q *Queries) GetUnclaimedInstallationsByUser(ctx context.Context, ghID sql.NullString) ([]ProviderGithubAppInstallation, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id int32) (User, error)

func (*Queries) GetUserBySubject

func (q *Queries) GetUserBySubject(ctx context.Context, identitySubject string) (User, error)

func (*Queries) GlobalListProviders

func (q *Queries) GlobalListProviders(ctx context.Context) ([]Provider, error)

func (*Queries) GlobalListProvidersByClass

func (q *Queries) GlobalListProvidersByClass(ctx context.Context, class ProviderClass) ([]Provider, error)

func (*Queries) InsertAlertEvent

func (q *Queries) InsertAlertEvent(ctx context.Context, arg InsertAlertEventParams) error

func (*Queries) InsertEvaluationRuleEntity

func (q *Queries) InsertEvaluationRuleEntity(ctx context.Context, arg InsertEvaluationRuleEntityParams) (uuid.UUID, error)

func (*Queries) InsertEvaluationStatus

func (q *Queries) InsertEvaluationStatus(ctx context.Context, arg InsertEvaluationStatusParams) (uuid.UUID, error)

func (*Queries) InsertRemediationEvent

func (q *Queries) InsertRemediationEvent(ctx context.Context, arg InsertRemediationEventParams) error

func (*Queries) ListArtifactsByRepoID

func (q *Queries) ListArtifactsByRepoID(ctx context.Context, repositoryID uuid.NullUUID) ([]Artifact, error)

func (*Queries) ListEvaluationHistory

func (q *Queries) ListEvaluationHistory(ctx context.Context, arg ListEvaluationHistoryParams) ([]ListEvaluationHistoryRow, error)

func (*Queries) ListFlushCache

func (q *Queries) ListFlushCache(ctx context.Context) ([]FlushCache, error)

func (*Queries) ListInvitationsForProject

func (q *Queries) ListInvitationsForProject(ctx context.Context, project uuid.UUID) ([]ListInvitationsForProjectRow, error)

ListInvitationsForProject collects the information visible to project administrators after an invitation has been issued. In particular, it *does not* report the invitation code, which is a secret intended for the invitee.

func (*Queries) ListOldestRuleEvaluationsByRepositoryId

func (q *Queries) ListOldestRuleEvaluationsByRepositoryId(ctx context.Context, repositoryIds []uuid.UUID) ([]ListOldestRuleEvaluationsByRepositoryIdRow, error)

ListOldestRuleEvaluationsByRepositoryId has casts in select statement as sqlc generates incorrect types. cast after MIN is required due to a known bug in sqlc: https://github.com/sqlc-dev/sqlc/issues/1965

func (*Queries) ListOrganizations

func (q *Queries) ListOrganizations(ctx context.Context, arg ListOrganizationsParams) ([]Project, error)

func (*Queries) ListProfilesInstantiatingRuleType

func (q *Queries) ListProfilesInstantiatingRuleType(ctx context.Context, ruleTypeID uuid.UUID) ([]string, error)

func (*Queries) ListProvidersByProjectID

func (q *Queries) ListProvidersByProjectID(ctx context.Context, projects []uuid.UUID) ([]Provider, error)

ListProvidersByProjectID allows us to list all providers for a given array of projects.

func (*Queries) ListProvidersByProjectIDPaginated

func (q *Queries) ListProvidersByProjectIDPaginated(ctx context.Context, arg ListProvidersByProjectIDPaginatedParams) ([]Provider, error)

ListProvidersByProjectIDPaginated allows us to lits all providers for a given project with pagination taken into account. In this case, the cursor is the creation date.

func (*Queries) ListRegisteredRepositoriesByProjectIDAndProvider

func (q *Queries) ListRegisteredRepositoriesByProjectIDAndProvider(ctx context.Context, arg ListRegisteredRepositoriesByProjectIDAndProviderParams) ([]Repository, error)

func (*Queries) ListRepositoriesAfterID

func (q *Queries) ListRepositoriesAfterID(ctx context.Context, arg ListRepositoriesAfterIDParams) ([]Repository, error)

func (*Queries) ListRepositoriesByProjectID

func (q *Queries) ListRepositoriesByProjectID(ctx context.Context, arg ListRepositoriesByProjectIDParams) ([]Repository, error)

func (*Queries) ListRuleTypesByProject

func (q *Queries) ListRuleTypesByProject(ctx context.Context, projectID uuid.UUID) ([]RuleType, error)

func (*Queries) ListTokensToMigrate

func (q *Queries) ListTokensToMigrate(ctx context.Context, arg ListTokensToMigrateParams) ([]ProviderAccessToken, error)

When doing a key/algorithm rotation, identify the secrets which need to be rotated. The criteria for rotation are:

  1. The encrypted_access_token is NULL (this should be removed when we make this column non-nullable).
  2. The access token does not use the configured default algorithm.
  3. The access token does not use the default key version.

This query accepts the default key version/algorithm as arguments since that information is not known to the database.

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) LockIfThresholdNotExceeded

func (q *Queries) LockIfThresholdNotExceeded(ctx context.Context, arg LockIfThresholdNotExceededParams) (EntityExecutionLock, error)

LockIfThresholdNotExceeded is used to lock an entity for execution. It will attempt to insert or update the entity_execution_lock table only if the last_lock_time is older than the threshold. If the lock is successful, it will return the lock record. If the lock is unsuccessful, it will return NULL.

func (*Queries) OrphanProject

func (q *Queries) OrphanProject(ctx context.Context, arg OrphanProjectParams) (Project, error)

OrphanProject is a query that sets the parent_id of a project to NULL.

func (*Queries) ReleaseLock

func (q *Queries) ReleaseLock(ctx context.Context, arg ReleaseLockParams) error

ReleaseLock is used to release a lock on an entity. It will delete the entity_execution_lock record if the lock is held by the given locked_by value.

func (*Queries) RepositoryExistsAfterID

func (q *Queries) RepositoryExistsAfterID(ctx context.Context, id uuid.UUID) (bool, error)

func (*Queries) SetCurrentVersion

func (q *Queries) SetCurrentVersion(ctx context.Context, arg SetCurrentVersionParams) error

func (*Queries) UpdateEncryptedSecret

func (q *Queries) UpdateEncryptedSecret(ctx context.Context, arg UpdateEncryptedSecretParams) error

func (*Queries) UpdateInvitationRole

func (q *Queries) UpdateInvitationRole(ctx context.Context, arg UpdateInvitationRoleParams) (UserInvite, error)

UpdateInvitationRole updates an invitation by its code. This is intended to be called by a user who has issued an invitation and then decided to change the role of the invitee.

func (*Queries) UpdateLease

func (q *Queries) UpdateLease(ctx context.Context, arg UpdateLeaseParams) error

func (*Queries) UpdateOrganization

func (q *Queries) UpdateOrganization(ctx context.Context, arg UpdateOrganizationParams) (Project, error)

func (*Queries) UpdateProfile

func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)

func (*Queries) UpdateProjectMeta

func (q *Queries) UpdateProjectMeta(ctx context.Context, arg UpdateProjectMetaParams) (Project, error)

func (*Queries) UpdateProvider

func (q *Queries) UpdateProvider(ctx context.Context, arg UpdateProviderParams) error

func (*Queries) UpdateReminderLastSentForRepositories

func (q *Queries) UpdateReminderLastSentForRepositories(ctx context.Context, repositoryIds []uuid.UUID) error

func (*Queries) UpdateRuleType

func (q *Queries) UpdateRuleType(ctx context.Context, arg UpdateRuleTypeParams) (RuleType, error)

func (*Queries) UpdateSelector

func (q *Queries) UpdateSelector(ctx context.Context, arg UpdateSelectorParams) (ProfileSelector, error)

func (*Queries) UpsertAccessToken

func (q *Queries) UpsertAccessToken(ctx context.Context, arg UpsertAccessTokenParams) (ProviderAccessToken, error)

func (*Queries) UpsertArtifact

func (q *Queries) UpsertArtifact(ctx context.Context, arg UpsertArtifactParams) (Artifact, error)

func (*Queries) UpsertBundle

func (q *Queries) UpsertBundle(ctx context.Context, arg UpsertBundleParams) error

SPDX-FileCopyrightText: Copyright 2024 The Minder Authors SPDX-License-Identifier: Apache-2.0 Bundles --

func (*Queries) UpsertInstallationID

func (*Queries) UpsertLatestEvaluationStatus

func (q *Queries) UpsertLatestEvaluationStatus(ctx context.Context, arg UpsertLatestEvaluationStatusParams) error

func (*Queries) UpsertProfileForEntity

func (q *Queries) UpsertProfileForEntity(ctx context.Context, arg UpsertProfileForEntityParams) (EntityProfile, error)

func (*Queries) UpsertProperty

func (q *Queries) UpsertProperty(ctx context.Context, arg UpsertPropertyParams) (Property, error)

func (*Queries) UpsertPropertyValueV1

func (q *Queries) UpsertPropertyValueV1(ctx context.Context, params UpsertPropertyValueV1Params) (Property, error)

UpsertPropertyValueV1 upserts a property value for an entity

func (*Queries) UpsertRuleInstance

func (q *Queries) UpsertRuleInstance(ctx context.Context, arg UpsertRuleInstanceParams) (uuid.UUID, error)

SPDX-FileCopyrightText: Copyright 2024 The Minder Authors SPDX-License-Identifier: Apache-2.0

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ReleaseLockParams

type ReleaseLockParams struct {
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
	LockedBy         uuid.UUID `json:"locked_by"`
}

type ReleaseStatus

type ReleaseStatus string
const (
	ReleaseStatusAlpha      ReleaseStatus = "alpha"
	ReleaseStatusBeta       ReleaseStatus = "beta"
	ReleaseStatusGa         ReleaseStatus = "ga"
	ReleaseStatusDeprecated ReleaseStatus = "deprecated"
)

func (*ReleaseStatus) Scan

func (e *ReleaseStatus) Scan(src interface{}) error

type RemediationEvent

type RemediationEvent struct {
	ID           uuid.UUID              `json:"id"`
	EvaluationID uuid.UUID              `json:"evaluation_id"`
	Status       RemediationStatusTypes `json:"status"`
	Details      string                 `json:"details"`
	Metadata     json.RawMessage        `json:"metadata"`
	CreatedAt    time.Time              `json:"created_at"`
}

type RemediationStatusTypes

type RemediationStatusTypes string
const (
	RemediationStatusTypesSuccess      RemediationStatusTypes = "success"
	RemediationStatusTypesFailure      RemediationStatusTypes = "failure"
	RemediationStatusTypesError        RemediationStatusTypes = "error"
	RemediationStatusTypesSkipped      RemediationStatusTypes = "skipped"
	RemediationStatusTypesNotAvailable RemediationStatusTypes = "not_available"
	RemediationStatusTypesPending      RemediationStatusTypes = "pending"
)

func (*RemediationStatusTypes) Scan

func (e *RemediationStatusTypes) Scan(src interface{}) error

type Repository

type Repository struct {
	ID               uuid.UUID      `json:"id"`
	Provider         string         `json:"provider"`
	ProjectID        uuid.UUID      `json:"project_id"`
	RepoOwner        string         `json:"repo_owner"`
	RepoName         string         `json:"repo_name"`
	RepoID           int64          `json:"repo_id"`
	IsPrivate        bool           `json:"is_private"`
	IsFork           bool           `json:"is_fork"`
	WebhookID        sql.NullInt64  `json:"webhook_id"`
	WebhookUrl       string         `json:"webhook_url"`
	DeployUrl        string         `json:"deploy_url"`
	CloneUrl         string         `json:"clone_url"`
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        time.Time      `json:"updated_at"`
	DefaultBranch    sql.NullString `json:"default_branch"`
	License          sql.NullString `json:"license"`
	ProviderID       uuid.UUID      `json:"provider_id"`
	ReminderLastSent sql.NullTime   `json:"reminder_last_sent"`
}

type RuleInstance

type RuleInstance struct {
	ID         uuid.UUID       `json:"id"`
	ProfileID  uuid.UUID       `json:"profile_id"`
	RuleTypeID uuid.UUID       `json:"rule_type_id"`
	Name       string          `json:"name"`
	EntityType Entities        `json:"entity_type"`
	Def        json.RawMessage `json:"def"`
	Params     json.RawMessage `json:"params"`
	CreatedAt  time.Time       `json:"created_at"`
	UpdatedAt  time.Time       `json:"updated_at"`
	ProjectID  uuid.UUID       `json:"project_id"`
}

type RuleType

type RuleType struct {
	ID                  uuid.UUID       `json:"id"`
	Name                string          `json:"name"`
	Provider            sql.NullString  `json:"provider"`
	ProjectID           uuid.UUID       `json:"project_id"`
	Description         string          `json:"description"`
	Guidance            string          `json:"guidance"`
	Definition          json.RawMessage `json:"definition"`
	CreatedAt           time.Time       `json:"created_at"`
	UpdatedAt           time.Time       `json:"updated_at"`
	SeverityValue       Severity        `json:"severity_value"`
	ProviderID          uuid.NullUUID   `json:"provider_id"`
	SubscriptionID      uuid.NullUUID   `json:"subscription_id"`
	DisplayName         string          `json:"display_name"`
	ReleasePhase        ReleaseStatus   `json:"release_phase"`
	ShortFailureMessage string          `json:"short_failure_message"`
}

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) BeginTransaction

func (s *SQLStore) BeginTransaction() (*sql.Tx, error)

BeginTransaction begins a new transaction

func (*SQLStore) CheckHealth

func (s *SQLStore) CheckHealth() error

CheckHealth checks the health of the database

func (*SQLStore) Commit

func (*SQLStore) Commit(tx *sql.Tx) error

Commit commits a transaction

func (*SQLStore) GetQuerierWithTransaction

func (*SQLStore) GetQuerierWithTransaction(tx *sql.Tx) ExtendQuerier

GetQuerierWithTransaction returns a new Querier with the provided transaction

func (*SQLStore) Rollback

func (*SQLStore) Rollback(tx *sql.Tx) error

Rollback rolls back a transaction

func (*SQLStore) WithTransactionErr

func (s *SQLStore) WithTransactionErr(fn func(querier ExtendQuerier) error) error

WithTransactionErr wraps an operation in a DB transaction. Compared with the `WithTransaction` function, this only returns errors and not values. Since this does not rely on generics, it can be modelled as a method and stubbed out more easily.

type SessionStore

type SessionStore struct {
	ID                int32                 `json:"id"`
	Provider          string                `json:"provider"`
	ProjectID         uuid.UUID             `json:"project_id"`
	Port              sql.NullInt32         `json:"port"`
	OwnerFilter       sql.NullString        `json:"owner_filter"`
	SessionState      string                `json:"session_state"`
	CreatedAt         time.Time             `json:"created_at"`
	RedirectUrl       sql.NullString        `json:"redirect_url"`
	RemoteUser        sql.NullString        `json:"remote_user"`
	EncryptedRedirect pqtype.NullRawMessage `json:"encrypted_redirect"`
	ProviderConfig    []byte                `json:"provider_config"`
}

type SetCurrentVersionParams

type SetCurrentVersionParams struct {
	CurrentVersion string    `json:"current_version"`
	ProjectID      uuid.UUID `json:"project_id"`
}

type Severity

type Severity string
const (
	SeverityUnknown  Severity = "unknown"
	SeverityInfo     Severity = "info"
	SeverityLow      Severity = "low"
	SeverityMedium   Severity = "medium"
	SeverityHigh     Severity = "high"
	SeverityCritical Severity = "critical"
)

func (*Severity) Scan

func (e *Severity) Scan(src interface{}) error

type Store

type Store interface {
	ExtendQuerier
	CheckHealth() error
	BeginTransaction() (*sql.Tx, error)
	GetQuerierWithTransaction(tx *sql.Tx) ExtendQuerier
	Commit(tx *sql.Tx) error
	Rollback(tx *sql.Tx) error
	WithTransactionErr(fn func(querier ExtendQuerier) error) error
}

Store provides all functions to execute db queries and transactions

func NewStore

func NewStore(db *sql.DB) Store

NewStore creates a new store

type Subscription

type Subscription struct {
	ID             uuid.UUID `json:"id"`
	ProjectID      uuid.UUID `json:"project_id"`
	BundleID       uuid.UUID `json:"bundle_id"`
	CurrentVersion string    `json:"current_version"`
}

type UpdateEncryptedSecretParams

type UpdateEncryptedSecretParams struct {
	ID     int32           `json:"id"`
	Secret json.RawMessage `json:"secret"`
}

type UpdateInvitationRoleParams

type UpdateInvitationRoleParams struct {
	Code string `json:"code"`
	Role string `json:"role"`
}

type UpdateLeaseParams

type UpdateLeaseParams struct {
	EntityInstanceID uuid.UUID `json:"entity_instance_id"`
	LockedBy         uuid.UUID `json:"locked_by"`
}

type UpdateOrganizationParams

type UpdateOrganizationParams struct {
	ID       uuid.UUID       `json:"id"`
	Name     string          `json:"name"`
	Metadata json.RawMessage `json:"metadata"`
}

type UpdateProfileParams

type UpdateProfileParams struct {
	ID          uuid.UUID      `json:"id"`
	ProjectID   uuid.UUID      `json:"project_id"`
	Remediate   NullActionType `json:"remediate"`
	Alert       NullActionType `json:"alert"`
	DisplayName string         `json:"display_name"`
	Labels      []string       `json:"labels"`
}

type UpdateProjectMetaParams

type UpdateProjectMetaParams struct {
	ID       uuid.UUID       `json:"id"`
	Metadata json.RawMessage `json:"metadata"`
}

type UpdateProviderParams

type UpdateProviderParams struct {
	Implements []ProviderType      `json:"implements"`
	Definition json.RawMessage     `json:"definition"`
	AuthFlows  []AuthorizationFlow `json:"auth_flows"`
	ID         uuid.UUID           `json:"id"`
	ProjectID  uuid.UUID           `json:"project_id"`
}

type UpdateRuleTypeParams

type UpdateRuleTypeParams struct {
	ID                  uuid.UUID       `json:"id"`
	Description         string          `json:"description"`
	Definition          json.RawMessage `json:"definition"`
	SeverityValue       Severity        `json:"severity_value"`
	DisplayName         string          `json:"display_name"`
	ReleasePhase        ReleaseStatus   `json:"release_phase"`
	ShortFailureMessage string          `json:"short_failure_message"`
}

type UpdateSelectorParams

type UpdateSelectorParams struct {
	ID       uuid.UUID    `json:"id"`
	Entity   NullEntities `json:"entity"`
	Selector string       `json:"selector"`
	Comment  string       `json:"comment"`
}

type UpsertAccessTokenParams

type UpsertAccessTokenParams struct {
	ProjectID            uuid.UUID             `json:"project_id"`
	Provider             string                `json:"provider"`
	ExpirationTime       time.Time             `json:"expiration_time"`
	OwnerFilter          sql.NullString        `json:"owner_filter"`
	EnrollmentNonce      sql.NullString        `json:"enrollment_nonce"`
	EncryptedAccessToken pqtype.NullRawMessage `json:"encrypted_access_token"`
}

type UpsertArtifactParams

type UpsertArtifactParams struct {
	RepositoryID       uuid.NullUUID `json:"repository_id"`
	ArtifactName       string        `json:"artifact_name"`
	ArtifactType       string        `json:"artifact_type"`
	ArtifactVisibility string        `json:"artifact_visibility"`
	ProjectID          uuid.UUID     `json:"project_id"`
	ProviderID         uuid.UUID     `json:"provider_id"`
	ProviderName       string        `json:"provider_name"`
}

type UpsertBundleParams

type UpsertBundleParams struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

type UpsertInstallationIDParams

type UpsertInstallationIDParams struct {
	OrganizationID    int64          `json:"organization_id"`
	AppInstallationID int64          `json:"app_installation_id"`
	ProviderID        uuid.NullUUID  `json:"provider_id"`
	EnrollingUserID   sql.NullString `json:"enrolling_user_id"`
	EnrollmentNonce   sql.NullString `json:"enrollment_nonce"`
	ProjectID         uuid.NullUUID  `json:"project_id"`
	IsOrg             bool           `json:"is_org"`
}

type UpsertLatestEvaluationStatusParams

type UpsertLatestEvaluationStatusParams struct {
	RuleEntityID        uuid.UUID `json:"rule_entity_id"`
	EvaluationHistoryID uuid.UUID `json:"evaluation_history_id"`
	ProfileID           uuid.UUID `json:"profile_id"`
}

type UpsertProfileForEntityParams

type UpsertProfileForEntityParams struct {
	Entity          Entities        `json:"entity"`
	ProfileID       uuid.UUID       `json:"profile_id"`
	ContextualRules json.RawMessage `json:"contextual_rules"`
}

type UpsertPropertyParams

type UpsertPropertyParams struct {
	EntityID uuid.UUID       `json:"entity_id"`
	Key      string          `json:"key"`
	Value    json.RawMessage `json:"value"`
}

type UpsertPropertyValueV1Params

type UpsertPropertyValueV1Params struct {
	EntityID uuid.UUID `json:"entity_id"`
	Key      string    `json:"key"`
	Value    any       `json:"value"`
}

UpsertPropertyValueV1Params is the input parameter for the UpsertProperty query

type UpsertRuleInstanceParams

type UpsertRuleInstanceParams struct {
	ProfileID  uuid.UUID       `json:"profile_id"`
	RuleTypeID uuid.UUID       `json:"rule_type_id"`
	Name       string          `json:"name"`
	EntityType Entities        `json:"entity_type"`
	Def        json.RawMessage `json:"def"`
	Params     json.RawMessage `json:"params"`
	ProjectID  uuid.UUID       `json:"project_id"`
}

type User

type User struct {
	ID              int32     `json:"id"`
	IdentitySubject string    `json:"identity_subject"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type UserInvite

type UserInvite struct {
	Code      string    `json:"code"`
	Email     string    `json:"email"`
	Role      string    `json:"role"`
	Project   uuid.UUID `json:"project"`
	Sponsor   int32     `json:"sponsor"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Directories

Path Synopsis
Package embedded provides a test-only embedded Postgres database for testing queries.
Package embedded provides a test-only embedded Postgres database for testing queries.
Package fixtures contains code for creating DB fixtures and is used in various parts of the code.
Package fixtures contains code for creating DB fixtures and is used in various parts of the code.

Jump to

Keyboard shortcuts

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